MSSQLServer JDBC Driver + Tomcat Configuration

You can only get the official driver direct from Microsoft (this link gives direct access without having to go through the #$@!ing .NET/Passport login). Note that Microsoft loves to rearrange their site every few weeks, so if the above link doesn't work, search their site for “JDBC.”

DO NOT DOWNLOAD Setup.exe. Get the .tar instead, because you have no idea what the .exe installs or where. Winzip recognizes .tar files, so you can use it to extract only the following three files:

  • mssqlserver.jar,
  • msbase.jar, and
  • msutil.jar

Tomcat

To set up tomcat, save the aforementioned jars in the common/lib and add the following to conf/server.xml (the items to change are CAPITALIZED):

  <Context path="/RELATIVE-PATH-TO-APP" docBase="?SOMETHING?">
    <Resource name="jdbc/?SOMETHINGELSE?" scope="Shareable" type="javax.sql.DataSource"/>
    <ResourceParams name="jdbc/?UHH...?">
        <parameter>
            <name>factory</name>
            <value>org.apache.commons.dbcp.BasicDataSourceFactory</value>
        </parameter>

        <!-- DBCP database connection settings -->
        <parameter>
            <name>url</name>
            <value>jdbc:microsoft:sqlserver://SERVERNAME:1433;DatabaseName=DBNAME[;SelectMethod=cursor]</value>
        </parameter>
        <parameter>
            <name>driverClassName</name>
            <value>com.microsoft.jdbc.sqlserver.SQLServerDriver</value>
        </parameter>
        <parameter>
            <name>username</name>
            <value>USERNAME</value>
        </parameter>
        <parameter>
            <name>password</name>
            <value>PASSWORD</value>
        </parameter>

        <!-- DBCP connection pooling options -->
        <parameter>
            <name>maxWait</name>
            <value>5000</value>
        </parameter>
        <parameter>
            <name>maxIdle</name>
            <value>2</value>
        </parameter>
        <parameter>
            <name>maxActive</name>
            <value>4</value>
        </parameter>

    </ResourceParams>
  </Context>

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值