Ivan
Ivan

Reputation: 64207

Where to put a user-editable database connection string for a Scala Lift web application?

I need to be able to configure a Scala Lift web application of mine with such things like a database connection string. Where should I best put such a data (I use Jetty for hosting) and how to access it from the application code?

Upvotes: 2

Views: 256

Answers (2)

Knut Arne Vedaa
Knut Arne Vedaa

Reputation: 15742

You could set up a Data Source in Jetty and connect to it like this:

val dataSource = (new InitialContext).lookup(name).asInstanceOf[DataSource]
val conn = dataSource.getConnection

where name is the name JNDI name of the data source, e.g. "java:jdbc/MyDB".

I don't know how you'd interface this to Lift, though, as I haven't used Lift.

Upvotes: 0

Debilski
Debilski

Reputation: 67838

You need to write a properties file in src/main/resources/props/ and may then access the data using, for example, Props.get("db.url").

Upvotes: 2

Related Questions