Tomcat6.0配置c3p0數據源

配置環境:tomcat-6.0.29
                 mysql-connector-5.1.6-bin.jar
                 c3p0-0.9.1.jar
                 jstl-1.1-standard.jar
                 jstl-1.1-jstl.jar
                 NetBeans-6.9.1
     KUbuntu 10.10

1.根據Tomcat6.0的說明文檔,首先將數據庫連接所用到的jar包導入。
2.編寫配置文件:content.xml
<?xml version="1.0" encoding="UTF-8"?>
<Context debug="5" reloadable="true" crossContext="true">

    
<Resource name="jdbc/CasDB"
       auth="Container"
       type="javax.sql.DataSource"
       driverClassName="com.mysql.jdbc.Driver"
       url="jdbc:mysql://localhost:3306/DB_CAS?useUnicode=true&amp;characterEncoding=utf8&amp;autoReconnect=true"
       username="root"
       password="123456"
  maxPoolSize="20"
  minPoolSize="20"
  initialPoolSize="20"
  maxIdleTime="7200"
  idleConnectionTestPeriod="3600"
  testConnectionOnCheckin="false"
  acquireIncrement="20"
  acquireRetryAttempts="30"
  acquireRetryDelay="1000"
  checkoutTimeout="5000"
  maxStatements="0"
  testConnectionOnCheckout="false"
  preferredTestQuery="select 1"
    />
        
</Context>
3.Tomcat6.0建議在web.xml中添加以下內容,但這不是必須的。
 <resource-ref>
      <res-ref-name>jdbc/dbtest</res-ref-name>
      <res-type>javax.sql.DataSource</res-type>
      <res-auth>Container</res-auth>
    </resource-ref>
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章