如果使用hibernate开发的话,对hibernate的配置了解清楚会很有帮助。下面是找资料总结的,如有错,请不吝指出,谢谢~
下面是关于JDBC连接配置中最重要的配置:
1. hibernate.connection.driver_class : 设置连接数据库的驱动.
2. hibernate.connection.url : 设置所需连接数据库服务的URL
3. hibernate.connection.username : 连接数据库的用户名
4. hibernate.connection.password : 连接数据库的密码
5. hibernate.connection.pool_size : 设置hibernate数据库连接池的最大并发连接数
6. hibernate.dialect : 设置连接数据库使用的方言
上面配置了Hibernate数据库连接池的最大连接并发数,但是Hibernate自带的连接池仅有测试价值。并不推荐在实际的项目中使用。实际项目中可以使用c3p0连接池。所以使用c3p0连接池配置代替hibernate.connection.poo_size即可。
c3p0配置如下:
1. hibernate.c3p0.max_size : c3p0连接池的最大连接数
2. hibernate.c3p0.min_size : c3p0连接池的最小连接数
3. hibernate.c3p0.timeout : c3p0连接池连接的超时时长,单位为秒
4. hibernate.c3p0.max_statements : c3p0缓存 Statement的数量数
故,完整的配置文件内容如下(使用MySQL数据库):
/p>
"-//Hibernate/Hibernate Configuration DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd">
com.mysql.jdbc.Driver
jdbc:mysql://localhost/onlinestore
root
root
true
20
1
1800
50
org.hibernate.dialect.MySQLDialect
分享到:
2010-02-01 10:01
浏览 2552
评论