Hibernate中使用Tomcat的連接池

Hibernate中使用Tomcat的連接池

Hibernate 配置
<hibernate-configuration>

    <session-factory>
        <!-- properties -->
        <property name="connection.datasource">java:comp/env/jdbc/REEL1</property>
        <property name="show_sql">true</property>

        <property name="dialect"></property>


        <!-- mapping files -->
        <mapping resource="com/gecs/steel/SIntro.hbm.xml"/>
        <mapping resource="com/gecs/steel/SStore.hbm.xml"/>

    </session-factory>

</hibernate-configuration>

-------------------------------------------------------
Tomcat 的Server.xml
<Resource name="jdbc/REEL1" auth="Container" type="javax.sql.DataSource"/>
 <ResourceParams name="jdbc/REEL1">
   <parameter>
     <name>factory</name>
     <value>org.apache.commons.dbcp.BasicDataSourceFactory</value>
   </parameter>
   <parameter>
     <name>driverClassName</name>
     <value>oracle.jdbc.driver.OracleDriver</value>
   </parameter>
   <parameter>
     <name>url</name>
     <value>jdbc:oracle:thin:@10.240.144.16:1521:SMT</value>
   </parameter>
   <parameter>
     <name>username</name>
     <value>smtuser</value>
   </parameter>
   <parameter>
     <name>password</name>
     <value>smtmanager</value>
   </parameter>
   <parameter>
     <name>maxActive</name>
     <value>100</value>
   </parameter>
   <parameter>
     <name>maxIdle</name>
     <value>60</value>
   </parameter>
   <parameter>
     <name>maxWait</name>
     <value>10000</value>
     </parameter>
   <parameter>
     <name>removeAbandoned</name>
     <value>true</value>
   </parameter>
     <parameter>
       <name>logAbandoned</name>
       <value>false</value>
     </parameter>
            <parameter>
       <name>removeAbandonedTimeout</name>
       <value>1</value>
     </parameter>
   </ResourceParams>

你可能感兴趣的:(Hibernate中使用Tomcat的連接池)