For example I want to connect to my database server, but have no desire to actually use any form of OR mapping.
So after googleing a bit and woundering how todo this. It's all rather simple.
In your Boot.scala file
def boot { // where to search snippet LiftRules.addToPackages("code") // Build SiteMap LiftRules.setSiteMap(sitemap) //rest based stuff /** * connection url for lift */ val vendor = new StandardDBVendor("org.postgresql.Driver","jdbc:postgresql://****/****",Full("username"),Full("password")) with ProtoDBVendor{ override def maxPoolSize = 100 override def doNotExpandBeyond = 200 } DB.defineConnectionManager(DefaultConnectionIdentifier, vendor) }
This basically defines what to connect to and a connection pool with a max of 100 connections.
To actually access this connection and todo something with it, well this is remarkable easy.
DB.performQuery("select * from data")
No comments:
Post a Comment