apache - reading DB credentials from props file in lift scala -


i started working scala , lift frame work. trying connect db using normal jdbc. wish read db credentials default.props file. tried following code far: in default.props file:

db.class=com.mysql.jdbc.driver db.url=jdbc:mysql://localhost/scalatest db.user=root db.password= 

and in boot.scala file trying jdbc connection this:

val filename = "/src/main/resources/props/default.props" props.wheretolook = () => ((filename, () => full(new fileinputstream(filename))) :: nil)  val dbdriver = props.get("db.class").tostring val dburl =  props.get("db.url").tostring val dbusrname =  props.get("db.user").tostring val dbpass = props.get("db.password").tostring  class.forname(dbdriver) val conn  = drivermanager.getconnection(dburl,dbusrname, dbpass) 

but while running server using container:start command, filenotfoundexception showing. can tel have here. thanx in advance.

delete line change props.wheretolook. should set right values. (more info on lift wiki)

a note: contents of src/main/resources folder added directly classpath @ runtime. file src/main/resources/props/default.props should available via call someclassinyourproject.getresourceasstream("/props/default.props"). don't try refer file in source directory @ runtime, ever cause headaches later on.


Comments

Popular posts from this blog

node.js - Bad Request - node js ajax post -

Why does Ruby on Rails generate add a blank line to the end of a file? -

keyboard - Smiles and long press feature in Android -