jsp+sqlserver2000+连接池 环境搭建
平台:
1.tomcat 6.0
2.server 2003
3.iis 6.0
4.java 1.6.0_02
5.sql server 2000
配置步骤:
1.在tomcat安装目录下c:tomcat\lib放入下好的三个微软驱动程序:msbase.jar,mssqlserver.jar,msutil.jar
2.建数据库test,建表test(name,id)
3.配置server.xml,放在下列代码 <host> </host> 之间
<Context path= "/test " docBase= "test " debug= "5 " reloadable= "true " crossContext= "true ">
<Resource name= "jdbc/TestDB " auth= "Container " type= "javax.sql.DataSource "/>
<ResourceParams name= "jdbc/TestDB ">
<parameter>
<name> factory </name>
<value> org.apache.commons.dbcp.BasicDataSourceFactory </value>
</parameter>
<!-- Maximum number of dB connections in pool. Make sure you
configure your MYSQLd max_connections large enough to handle
all of your db connections. Set to 0 for no limit.
-->
<parameter>
<name> maxActive </name>
<value> 100 </value>
</parameter>
<!-- Maximum number of idle dB connections to retain in pool.
Set to 0 for no limit.
-->
<parameter>
<name> maxIdle </name>
<value> 30 </value>
</parameter>
<!-- Maximum time to wait for a dB connection to become available
in ms, in this example 10 seconds. An Exception is thrown if
this timeout is exceeded. Set to -1 to wait indefinitely.
-->
<parameter>
<name> maxWait </name>
<value> 10000 </value>
</parameter>
<!-- MSSQLserver dB username and password for dB connections -->
<parameter>
<name> username </name>
<value> sa </value>
</parameter>
<parameter>
<name> password </name>
<value> sa </value>
</parameter>
<!-- Class name for mssqlserver JDBC driver -->
<parameter>
<name> driverClassName </name>
<value> com.microsoft.jdbc.sqlserver.SQLServerDriver </value>
</parameter>
<!-- The JDBC connection url for connecting to your mssqlserver dB.-->
<parameter>
<name> url </name>
<value> jdbc:microsoft:sqlserver://127.0.0.1:1433;DatabaseName=test </value>
</parameter>