如果使用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

分享到:

18e900b8666ce6f233d25ec02f95ee59.png

72dd548719f0ace4d5f9bca64e1d7715.png

2010-02-01 10:01

浏览 2552

评论

Logo

魔乐社区(Modelers.cn) 是一个中立、公益的人工智能社区,提供人工智能工具、模型、数据的托管、展示与应用协同服务,为人工智能开发及爱好者搭建开放的学习交流平台。社区通过理事会方式运作,由全产业链共同建设、共同运营、共同享有,推动国产AI生态繁荣发展。

更多推荐