JDBC连接
hibernate.connection.driver_class jdbc驱动类
hibernate.connection.url jdbc URL jdbc:mysql://localhost:3306/task?autoReconnect=true
自动重连
hibernate.connection.username 数据库用户
hibernate.connection.password 数据库用户密码
hibernate.dialect 一个Hibernate Dialect类名允许Hibernate针对特定的关系数据库生成优化的SQL
-
MySQL
org.hibernate.dialect.MySQLDialect
-
MySQL
with InnoDB org.hibernate.dialect.MySQLInnoDBDialect
-
Oracle
org.hibernate.dialect.OracleDialect
-
Oracle 9i/10g
org.hibernate.dialect.Oracle9Dialect
-
Microsoft SQL Server
org.hibernate.dialect.SQLServerDialect
hibernate.show_sql 输出所有SQL语句到控制台 true | false
hibernate.format_sql 在log和console中打印出更漂亮的SQL true | false
Hibernate JDBC和连接(connection)属性
hibernate.jdbc.fetch_size 非零值,指定JDBC抓取数量的大小
hibernate.jdbc.batch_size 非零值,允许Hibernate使用JDBC2的批量更新.取值 建议取5到30之间的值
hibernate.connection.release_mode 指定Hibernate在何时释放JDBC连接.
on_close | after_transaction | after_statement | auto;JTA数据源
使用 after_statement
在每次JDBC调用后,都会主动的释放连接;对于非JTA
的连接, 使用after_transaction
在每个事务结束时释放
连接是合理的;auto将为JTA和CMT事务策略选择after_statement, 为JDBC事务策略选择after_transaction.
Hibernate缓存属性
hibernate.cache.provider_class 自定义的CacheProvider的类名"org.hibernate.connection.C3P0ConnectionProvider
"
hibernate.cache.use_query_cache 允许查询缓存 true|false
hibernate.cache.use_second_level_cache 能用来完全禁止使用二级缓存 true|false
c3p0连接池设置:C3P0是一个随Hibernate一同分发的开源的JDBC连接池
参考:http://image.bigad.cn/blog/?p=4
<!-- 当连接池中的连接耗尽
的时候c3p0一次同时获取的连接数
-->
<property name="hibernate.c3p0.initialPoolSize">3</property>
<!-- 最大连接数
-->
<property name="hibernate.c3p0.max_size">20</property>
<!-- 最小连接数
-->
<property name="hibernate.c3p0.min_size">5</property>
<!-- 获得连接的超时时间
,如果超过这个时间,会抛出异常,单位毫秒 -->
<property name="hibernate.c3p0.timeout">120</property>
<!-- 最大的PreparedStatement
的数量 -->
<property name="hibernate.c3p0.max_statements">100</property>
<!-- 每隔120秒检查连接池里的空闲连接
,单位是秒-->
<property name="hibernate.c3p0.idle_test_period">120</property>
<!-- 当连接池里面的连接用完的时候,C3P0一下获取的新的连接数
-->
<property name="hibernate.c3p0.acquire_increment">2</property>
<!-- 每次都验证连接
是否可用 -->
<property name="hibernate.c3p0.validate">true</property>
<!--最大空闲时间
,60秒内未使用则连接被丢弃。若为0则永不丢弃。Default: 0 -->
<property name="hibernate.c3p0.maxIdleTime">60</property>
<!--c3p0是异步操作的,缓慢的JDBC操作通过帮助进程
完成。扩展这些操作可以有效的提升性能通过多线程实现多个操作同时被执行。Default: 3-->
<property name="hibernate.c3p0.numHelperThreads">10</property>
<!--每60秒
检查所有连接池中的空闲连接
。Default: 0 -->
<property name="hibernate.c3p0.idleConnectionTestPeriod">60</property>
<!--如果设为true那么在取得连接的同时将校验连接的有效性
。Default: false -->
<property name="hibernate.c3p0.testConnectionOnCheckin">true</property>
<!--因性能消耗大请只在需要的时候使用它。如果设为true那么在每个connection提交的时候
都将校验其有效性
。建议使用idleConnectionTestPeriod或automaticTestTable等方法来提升连接测试的性能。Default: false -->
<property name="hibernate.c3p0.testConnectionOnCheckout">false</property>
分享到:
相关推荐
hibernate.cfg.xml hibernate框架的配置文件
(hibernate调用C3p0)hibernate.cfg.xml
Hibernate配置文件hibernate.cfg.xml中配置信息详解!
高级Hibernate4开发技术:ORM思想,hibernate介绍,hibernate.cfg.xml配置,hbm.xml映射文件详解,主键生成策略使用,PO对象状态及状态的转换分析、一级缓存,Hibernate数据检索技术,Hibernate高级映射技术,...
由于spring对hibernate配置文件hibernate.cfg.xml的集成相当好,可以在项目中放弃hibernate.cfg.xml文件,介绍mappingLocations、mappingDirectoryLocations与mappingJarLocations的用法和区别
Hibernate.cfg.xml配置总结
高级Hibernate4开发技术:ORM思想,hibernate介绍,hibernate.cfg.xml配置,hbm.xml映射文件详解,主键生成策略使用,PO对象状态及状态的转换分析、一级缓存,Hibernate数据检索技术,Hibernate高级映射技术,...
这是Hibernate的配置文件,hibernate.cfg.xml的具体写法,共友友们参考~~谢谢~
hibernate.cfg.xml文件详细解释收集的一个比较好的hibernate.cfg.xml文件解释
hibernate配置文件hibernate.cfg.xml的详细解释
hibernate.cfg.xml中配置信息详解
hibernate.cfg.xml中各节点的所有属性值,取自hibernate官网,纯天然无污染。原装!
Hibernate4的全套jar包,及hbm.xml(模板)+hibernate.cfg.xml(模板)+c3p0(全套)+ojdbc14.jar
NULL 博文链接:https://javawjy.iteye.com/blog/804577