在Tomcat上配置SQL Server连接池 [英] Configure SQL Server connection pool on Tomcat

查看:252
本文介绍了在Tomcat上配置SQL Server连接池的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直在尝试为SQL Server 2012数据库配置连接池。我目前已经配置并运行了Informix和Oracle池,只有SQL Server让我头疼。这是我在Context.xml上的资源到目前为止的样子:

I've been trying to configure a connection pool for a SQL Server 2012 database. I currently have Informix and Oracle pools configured and working, only SQL Server is giving me a headache. This is how my resource on Context.xml looks so far:

<Resource name="jdbc/sqlserv"
    auth="Container"
    factory="org.apache.tomcat.dbcp.dbcp.BasicDataSourceFactory"
    driverClass="com.microsoft.sqlserver.jdbc.SQLServerDriver"
    type="javax.sql.DataSource"
    maxActive="50"
    maxIdle="10"
    maxWait="15000"
    username="username"
    password="password"
    url="jdbc:sqlserver://127.0.0.1:1433;databaseName=SQLDB;"
    removeAbandoned="true"
    removeAbandonedTimeout="30"
    logAbandoned="true" /> 

当然,那是使用sqljdbc4驱动程序。我们已经尝试将jtds-1.3.0与 driverClass =net.sourceforge.jtds.jdbc.Driver一起使用,但是没有去。所有资源引用也正在正确配置。每当我尝试使用该资源创建新连接时,它都会失败。

为了便于比较,以下是我们的Informix和Oracle资源的样子:

That's using sqljdbc4 driver, of course. We already tried using jtds-1.3.0 with the driverClass="net.sourceforge.jtds.jdbc.Driver", but no go. All the resource-refs are also being correctly configured. Whenever I try to create a new connection using that Resource, it fails.
For comparison's sake, here's how our Informix and Oracle resources look like:

<Resource name="jdbc/infmx"
    auth="Container"
    type="javax.sql.DataSource"
    factory="org.apache.tomcat.dbcp.dbcp.BasicDataSourceFactory"
    maxActive="50"
    maxIdle="10"
    maxWait="15000"
    username="username"
    password="password"
    driverClassName="com.informix.jdbc.IfxDriver"
    url="jdbc:informix-sqli://localhost:30091/infmx:informixserver=ol_infmx_soc"
    removeAbandoned="true"
    removeAbandonedTimeout="30"
    logAbandoned="true"/>

<Resource name="jdbc/orcl"
    auth="Container"
    type="oracle.jdbc.pool.OracleDataSource"
    driverClassName="oracle.jdbc.driver.OracleDriver"
    factory="oracle.jdbc.pool.OracleDataSourceFactory"
    url="jdbc:oracle:thin:@127.0.0.1:1521:orcl"
    user="username"
    password="password"
    maxActive="50"
    maxIdle="10"
    maxWait="15000" /> 

所以我的问题是:如何在我的tomcat上下文中为SQL Server 2012正确配置连接池?我搜索过高低,尝试了我发现的所有内容,但没有任何效果。

So My question is: How can I correctly configure a connection pool for SQL Server 2012 on my tomcat context? I've searched high and low, attempted everything I've found, but nothing worked.


提前致谢。

[edit] 以下是堆栈跟踪: http://pastebin.com/ w3rZSERs

[edit-2] 似乎问题是Tomcat无法在他的lib文件夹中找到驱动程序。我们很确定它在那里,但我们不知道这一点。 sqljdbc4和jtds-1.3.0都会发生这种情况。我们遵循我们可以找到的每个指南,但问题仍然存在。

[edit-2] It seems the problem is that Tomcat can't find the driver on his lib folder. We're pretty sure it's there, but we don't know to be sure of that. This happens with both sqljdbc4 and jtds-1.3.0. We're following every guideline we can find, but the problem persists.

推荐答案

我们发现了问题。

driverClass="com.microsoft.sqlserver.jdbc.SQLServerDriver"

应该是

driverClassName="com.microsoft.sqlserver.jdbc.SQLServerDriver"

这篇关于在Tomcat上配置SQL Server连接池的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆