Reputation: 64207
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
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
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