如何连接Lift和MySQL?

问题描述:

我想创建一个简单的Lift Web应用程序,该应用程序读取输入表单并将其插入数据库.

I want to create a simple lift web application which read input throug form and insert it into database.

您需要将mysql jdbc驱动程序添加到您的项目中(作为Maven构件,或通过sbt,或只是将jar放在CLASSPATH中)并编辑属性文件(道具/default.props):

You need to add mysql jdbc driver to your project (as a maven artifact, or via sbt, or just put jar in CLASSPATH) and edit properties file (props/default.props):

db.driver=com.mysql.jdbc.Driver
db.url=jdbc:mysql://localhost/your_db_name
db.user=user
db.password=password

此外,您可以改为在应用程序容器(Tomcat等)中设置数据库上下文.之后,您可以使用Lift的ORM(映射器).

Also, you can setup db context in app container (Tomcat, etc.) instead. After that you can use Lift's ORM (Mapper).