O'Reilly logo

Lift Application Development Cookbook by Gilberto T. Garcia Jr.

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Configuring a connection to database

The first thing we need to learn while working with databases is how to connect the application that we will build with the database itself.

In this recipe, we will show you how to configure Lift to connect with the database of our choice. For this recipe, we will use PostgreSQL; however, other databases can also be used:

Getting ready

  1. Start a new blank project.
  2. Edit the build.sbt file to add the lift-mapper and PostgreSQL driver dependencies:
    "net.liftweb" %% "lift-mapper" % liftVersion % "compile",
    "org.postgresql" % "postgresql" % "9.2-1003-jdbc4"  % "compile"
  3. Create a new database.
  4. Create a new user.

How to do it...

Now carry out the following steps to configure a connection with the database:

  1. Add the following lines ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required