开源技术之Tomcat数据源配置总结

1/5/2008来源:Java教程人气:4714

成功配置环境Tomcat5.0.28+MSSQLServer2000+MS JDBC Driver

一、    安装Tomcat5.0.28

二、    安装MS JDBC Driver
假设安装路径是F:\green\Microsoft SQL Server 2000 JDBC,那么在F:\green\Microsoft SQL Server 2000 JDBC\lib下面有三个文件msbase.jar、sqlserver.jar、msutil.jar,并将此三个文件复制到%TOMMCAT_HOME%\common\lib目录下

三、    注册JNDI数据源
修改%TOMCAT_HOME%\conf\Catalina\localhost\目录下您的应用程序对应的配置文件
如:我的一个应用WebDemo.xml文件如下:
<?xml version='1.0' encoding='utf-8'?>
<Context workDir="work\Catalina\localhost\WebDemo" path="/WebDemo" docBase="D:\jakarta-tomcat-5.0.28\webapps\WebDemo">
    <Resource type="javax.sql.DataSource"  auth="Container"  name="jdbc/northwind"/>  
    <ResourceParams name="jdbc/northwind">
      <parameter>
        <name>maxWait</name>
        <value>5000</value>
      </parameter>
      <parameter>
        <name>maxActive</name>
        <value>4</value>
      </parameter>
      <parameter>
        <name>passWord</name>
        <value>jckjdkmcj</value>
      </parameter>
      <parameter>
        <name>url</name>
        <value>jdbc:microsoft:sqlserver://10.0.0.168:1433;databaseName=northwind</value>
      </parameter>
      <parameter>
        <name>driverClassName</name>
        <value>com.microsoft.jdbc.sqlserver.SQLServerDriver</value>
      </parameter>
      <parameter>
        <name>maxIdle</name>
        <value>2</value>
      </parameter>
      <parameter>
        <name>username</name>
        <value>sa</value>
      </parameter>
    </ResourceParams>
   <Resource type="javax.sql.DataSource" name="jdbc/zydb"/>
    <ResourceParams name="jdbc/zydb">
      <parameter>
        <name>url</name>
        <value>jdbc:Oracle:thin:@10.0.0.168:1521:ZYDB</value>
      </parameter>
      <parameter>
        <name>password</name>
        <value>jckjdkmcj</value>
      </parameter>
      <parameter>
        <name>maxActive</name>
        <value>4</value>
      </parameter>
      <parameter>
        <name>maxWait</name>
        <value>5000</value>
      </parameter>
      <parameter>
        <name>driverClassName</name>
        <value>oracle.jdbc.driver.OracleDriver</value>
      </parameter>
      <parameter>
        <name>username</name>
        <value>zhangyi</value>
      </parameter>
      <parameter>
        <name>maxIdle</name>
        <value>2</value>
      </parameter>
    </ResourceParams>
</Context>