Using MySql with Lift
I need to use MySQL with my Lift webapp and here’s how I did it. In Boot.scala I replaced the Derby DBVendor object with a MySQL object. Hope that helps.
Add this to your pom.xml:
<dependency>
<groupid>mysql</groupid>
<artifactid>mysql-connector-java</artifactid>
<version>5.0.41</version>
</dependency>
object DBVendor extends ConnectionManager {
def newConnection(name: ConnectionIdentifier): Can[Connection] = {
try
{
Class.forName(”com.mysql.jdbc.Driver”)
val dm = DriverManager.getConnection(”jdbc:mysql://localhost:3306/database_name”, “user”, “password”)
Full(dm)
}
catch
{
case e : Exception => e.printStackTrace; Empty
}
}
def releaseConnection(conn: Connection)
{
conn.close
}
}
Next up is learning how to set up my domain objects properly.
