1. Hibernate默认连接池
2. C3P0连接池
3. Proxool连接池
4. JNDI DataSource
1. Hibernate默认连接池
<session-factory>
<property name="hibernate.connection.driver_class">
com.mysql.jdbc.Driver
</property>
<property name="hibernate.connection.url">
jdbc:mysql://127.0.0.1:3306/txazo
</property>
<property name="hibernate.connection.username">root</property>
<property name="hibernate.connection.password">root</property>
<property name="hibernate.connection.pool_size">10</property>
<property name="hibernate.dialect">
org.hibernate.dialect.MySQLDialect
</property>
<property name="hibernate.current_session_context_class">thread</property>
<property name="hibernate.show_sql">true</property>
<property name="hibernate.format_sql">true</property>
<property name="hibernate.hbm2ddl.auto">update</property>
<mapping class="com.txazo.domain.User" />
</session-factory>
2. C3P0连接池
<session-factory>
<property name="hibernate.connection.driver_class">
com.mysql.jdbc.Driver
</property>
<property name="hibernate.connection.url">
jdbc:mysql://127.0.0.1:3306/txazo
</property>
<property name="hibernate.connection.username">root</property>
<property name="hibernate.connection.password">root</property>
<property name="hibernate.c3p0.min_size">5</property>
<property name="hibernate.c3p0.max_size">20</property>
<property name="hibernate.c3p0.timeout">1000</property>
<property name="hibernate.c3p0.max_statements">100</property>
<property name="hibernate.dialect">
org.hibernate.dialect.MySQLDialect
</property>
<property name="hibernate.current_session_context_class">thread</property>
<property name="hibernate.show_sql">true</property>
<property name="hibernate.format_sql">true</property>
<property name="hibernate.hbm2ddl.auto">update</property>
<mapping class="com.txazo.domain.User" />
</session-factory>
3. Proxool连接池
1)添加Proxool的JAR包
2)src/proxool.xml
<?xml version="1.0" encoding="UTF-8"?>
<something-else-entirely>
<proxool>
<alias>txazo</alias>
<driver-url>jdbc:mysql://127.0.0.1:3306/txazo</driver-url>
<driver-class>com.mysql.jdbc.Driver</driver-class>
<driver-properties>
<property name="user" value="root" />
<property name="password" value="root" />
</driver-properties>
<minimum-connection-count>5</minimum-connection-count>
<maximum-connection-count>20</maximum-connection-count>
</proxool>
</something-else-entirely>
3)src/hibernate.cfg.xml
<session-factory>
<property name="hibernate.connection.provider_class">
org.hibernate.connection.ProxoolConnectionProvider
</property>
<property name="hibernate.proxool.pool_alias">txazo</property>
<property name="hibernate.proxool.xml">proxool.xml</property>
<property name="hibernate.dialect">
org.hibernate.dialect.MySQLDialect
</property>
<property name="hibernate.current_session_context_class">thread</property>
<property name="hibernate.show_sql">true</property>
<property name="hibernate.format_sql">true</property>
<property name="hibernate.hbm2ddl.auto">update</property>
<mapping class="com.txazo.domain.User" />
</session-factory>
4. JNDI DataSource
<session-factory>
<property name="hibernate.connection.datasource">
java:comp/env/jdbc/txazo
</property>
<property name="hibernate.dialect">
org.hibernate.dialect.MySQLDialect
</property>
<property name="hibernate.current_session_context_class">thread</property>
<property name="hibernate.show_sql">true</property>
<property name="hibernate.format_sql">true</property>
<property name="hibernate.hbm2ddl.auto">update</property>
<mapping class="com.txazo.domain.User" />
</session-factory>
分享到:
相关推荐
hibernate配置数据库连接池的三种方法(数据库连接池的概念)
hibernate配置数据库连接池的三种方法.pdf
hibernate连接数据库的连接配置。包括oracle等一系列配置。
Hibernate配置文件中配置各种数据库的driver、URL
hibernate映射的创建数据库连接时的配置。教你怎么写那个配置。
在Hibernate的配置文件中,我们可以使用元素来设置数据库连接的各种属性,例如驱动程序的类名、连接URL、用户名、密码等。以SQL Server为例,我们可以使用以下配置: <property name="connection.driver_class">...
文档中列出了hibernate连接各种数据库的配置,同时也提供了使用c3p0连接各种数据库的配置,非常方便您的开发。
设置在 hibernate.cfg.xml文件中,hibernate与数据库的连接
hibernate数据库连接池配置。使用非常方便,参考数据库连接池配置
Hibernate连接SQLite配置步骤: 1、添加SQLite库: 1.1、将两个jar包:com.zy.hibernate.dialect.SQLiteDialect.jar、sqlite-jdbc-3.7.2.jar拷贝到“\WEB-INF\lib”文件夹下; 2、配置hibernate: 2.1、将...
hibernate同时配置多个数据库连接 可以同时连接不同IP的不同数据库
在工程的配置文件中填写数据库密码的密文,在应用程序使用datasource的时候解密成明文以创建连接。
hibernate 数据库 连接池包文件,自己找了很多网站才找到的,传到CSDN方便需要的人使用
达梦数据库各版本的hibernate方言包,包含版本 DmDialect-for-hibernate2.0、DmDialect-for-hibernate2.1、DmDialect-for-hibernate3.0、DmDialect-for-hibernate3.1、DmDialect-for-hibernate3.6、DmDialect-for-...
proxool-0.9.1(my).jar 包是我修改了proxool-0.9.1后的jar包,修改后可以完全支持spring配置,并添加了charSet配置属性,用于配置数据库链接的设置默认字符集,并且解决了proxool数据库连接池报如下错误的问题:...
hibernate配置文件 里面提供了连接数据库 数据库使用的方言 是否打印SQL语句 sql语句的格式 以及对象-关系映射文件的地址等
这是最新的hibernate的下载和安装包。hibernate配置文件主要是用于配置数据库连接、事务管理,以及指定hibernate本省的配置信息和hibernate的映射文件信息。
hibernate环境配置需要加载的各类包全集。 hibernate-3.1/ hibernate-commons-annotations-3.2.0.Final/ hibernate-core-5.3.0.Final-sources/ hibernate-entitymanager-5.3.0.Final/ hibernate-jpa-2.0-api-1.0.1....