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>

博客介绍了获取Microsoft SQL Server官方JDBC驱动的方法,建议从微软官网直接获取,不要下载Setup.exe,而是选择.tar文件。还提到使用Winzip提取所需的三个jar文件。此外,说明了在Tomcat中配置这些驱动的步骤,需将jar文件保存到common/lib并修改conf/server.xml。
1911

被折叠的 条评论
为什么被折叠?



