Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
219 views
in Technique[技术] by (71.8m points)

java - Configure SQL Server connection pool on Tomcat

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" /> 

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" /> 

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.


Thanks in advance.

[edit] Here's the stack trace: http://pastebin.com/w3rZSERs

[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.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

We found our problem.

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

Should have been

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

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...