play 集成squeryl ORM持久化框架

本文指导如何通过SBT配置Squeryl依赖,实现与多种数据库的交互,包括H2、MySQL、PostgreSQL等。详细介绍了依赖声明、数据库依赖选择及基本操作流程。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

The recommended version is 0.9.5-6

Supported Scala versions are 2.10.0, 2.9.2, 2.9.1, 2.9.0, 2.8.1 and 2.8.0

SBT

After having setup your project to use SBT (see how to setup SBT)
Declare the Squeryl dependency in the SBT project definiition

01libraryDependencies  ++=  Seq(
02  "org.squeryl" %% "squeryl" % "0.9.5-6",
03  yourDatabaseDependency
04)
05  
06//yourDatabaseDependency is one of the supported databases :
07 
08val h2 = "com.h2database" % "h2" % "1.2.127"
09val mysqlDriver = "mysql" % "mysql-connector-java" % "5.1.10"
10val posgresDriver = "postgresql" % "postgresql" % "8.4-701.jdbc4"
11val msSqlDriver = "net.sourceforge.jtds" % "jtds" % "1.2.4"
12val derbyDriver = "org.apache.derby" % "derby" % "10.7.1.1"

Note : The Oracle driver is not available via SBT/Maven, you will have to downloaded manually.

The remaining steps are :

  1. Bootstrap the session factory
  2. Define, and initialise a schema

You should now be ready to insert, update, delete data, and of course run queries.

Manual dependency management

If you want to manage your dependencies without SBT or Maven, you will need the following jars :

  • The Scala runtime jar, version 2.10.0, 2.9.2, 2.9.1 (or 2.9.0, 2.8.1, 2.8.0)
  • The Squeryl jar found here
  • The CGLIB cglib-nodep-2.2.jar, found here
  • A JDBC driver for your database, see supported databases
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值