<pre name="code" class="html"><span style="font-size:18px;">一、tomcat/server.xml
<Context path="/xwebTest" docBase="D:\apache-tomcat-6.0.30\webapps\xwebTest">
<Resource name="jndiSource"
auth="Container"
type="javax.sql.DataSource"
driverClassName="oracle.jdbc.driver.OracleDriver"
url="jdbc:oracle:thin:@59.44.47.154:1521:orcl"
username="webadmin"
password="begin110"
maxActive="1"
maxIdle="1"
maxWait="10000"/>
<WatchedResource>WEB-INF/web.xml</WatchedResource>
</Context>
二、web.xml
<resource-ref>
<description>dbConn</description>
<res-ref-name>jndiSource</res-ref-name>
<res-type>javax.sql.DataSource</res-type>
<res-auth>Container</res-auth>
</resource-ref>
三、hibernate.cfg.xml
<?xml version="1.0" encoding="gb2312"?>
<!DOCTYPE hibernate-configuration PUBLIC
"-//Hibernate/Hibernate Configuration DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd">
<hibernate-configuration>
<session-factory name="default">
<property name="connection.datasource">java:/comp/env/jndiSource</property>
<property name="dialect">org.hibernate.dialect.Oracle9iDialect</property>
<property name="use_outer_join">true</property>
<property name="transaction.factory_class">org.hibernate.transaction.JDBCTransactionFactory</property>
<property name="hibernate.query.factory_class ">org.hibernate.hql.classic.ClassicQueryTranslatorFactory</property>
<property name="hibernate.connection.provider_class">org.hibernate.connection.DatasourceConnectionProvider</property>
<property name="show_sql">true</property>
<property name="hibernate.jdbc.fetch_size">50</property>
<property name="hibernate.jdbc.batch_size">20</property>
<property name="hibernate.query.substitutions">true 1, false 0</property>
<property name="hibernate.max_fetch_depth">5</property>
</session-factory>
</hibernate-configuration>
</span>
数据库连接池配置
最新推荐文章于 2019-08-28 13:31:38 发布