Tomcat5使用连接池MSSQL2005/2000

1。下载 sqljdbc_1.0.809.102_chs_for2005.exe,解压后把sqljdbc.exe复制到D:\Java\tomcat-5.0.30\common\lib
2。增加 Context 的内容如下:
  <Context path="/test" docBase="test"
                    debug="5" reloadable="true" crossContext="true">
            <Logger className="org.apache.catalina.logger.FileLogger"
prefix="localhost_startcom_log." suffix=".txt"
                            timestamp="true"/>
              <resource name="jdbc/test"    auth="Container"
  type="javax.sql.DataSource">
               </resource>
   < ResourceParams name ="jdbc/test" >
                 < parameter >
                     < name >factory </name>
                     < value >org.apache.commons.dbcp.BasicDataSourceFactory </value>
                 </parameter>
             < parameter >
                     < name >maxActive </name>
                     < value >100 </value>
                 </parameter>
                 < parameter >
                     < name >maxIdle </name>
                     < value >30 </value>
                 </parameter>
                 < parameter >
                     < name >maxWait </name>
                     < value >10000 </value>
                 </parameter>
                 < parameter >
                     < name >username </name>
                     < value >test </value>
                 </parameter>
                 < parameter >
                     < name >password </name>
                     < value >123 </value>
                 </parameter>
                 < parameter >
                         < name >driverClassName </name>
                         < value >com.microsoft.sqlserver.jdbc.SQLServerDriver </value>
                 </parameter>
                 < parameter >
                     < name >url </name>
                     < value >jdbc:sqlserver://172.0.0.1;database=testdb;user=test;password=123 </value>
 
<!-- MSSQL2005 需要端口1433 -->
 
 <!--  < value >jdbc:sqlserver://172.0.0.1:1433;database=testdb;user=test;password=123 </value> -->

                   </parameter>
             </ResourceParams>            
         </Context>
其中URL与MSSQL2000的连接不同。
 
 
也有这样写:
 
在sql server 2000 中加载驱动和URL路径的语句是
String driverName = "com.microsoft. jdbc. sqlserver.SQLServerDriver";
String dbURL = " jdbc: microsoft:sqlserver://localhost:1433; DatabaseName=sample";
而sql server 2005 中加载驱动和url的语句则为
String driverName = "com.microsoft. sqlserver. jdbc.SQLServerDriver";
String dbURL = " jdbc:sqlserver://localhost:1433; DatabaseName=sample";
如果写法错误将会找不到驱动.
拷贝至此,已作参考。
 

你可能感兴趣的:(数据库,连接池,tomcat5,休闲,MSSQL2005/2000)