KingTravisG
KingTravisG

Reputation: 1336

Tomcat 7 Connection Pool Issue

I seem to have stumbled across a weird behavior with tomcat 7 and connection pooling...

In my app, I have the following 3 data sources - connecting to the same database, but different services ( and are the same across all 3)

jdbc:sybase:Tds:<db_ip_address>:<db_port>/service1
jdbc:sybase:Tds:<db_ip_address>:<db_port>/service2
jdbc:sybase:Tds:<db_ip_address>:<db_port>/service3

In my context.xml, I have the 3 data sources listed as a separate resource as usual, with all neccessary options set, including

<Resource
    name="jdbc/dbDataSource1"
    type="javax.sql.DataSource"
    driverClassName="com.sybase.jdbc3.jdbc.SybDriver"
    factory="org.apache.tomcat.jdbc.pool.DataSourceFactory"
    maxActive="20"
    initialSize="1"
    minIdle="5"
    maxIdle="10"

<Resource
    name="jdbc/dbDataSource2"
    <!-- Rest is same as above -->

<Resource
    name="jdbc/dbDataSource3"
    <!-- Rest is same as above -->

What I have noticed is, because the 3 data sources connect to the same database, tomcat only seems to be creating and using one connection pool and sharing between all 3. This can be seen at startup, where if I change initialSize to say 10, the first 2 data sources are created no problem - on the 3rd, I get an exception saying

java.sql.SQLException: JZ00L: Login failed. 
Examine the SQLWarnings chained to this exception for the reason(s).

Am I missing something obvious here on how to set up the connection pool? I have looked at the tomcat documentation and stuff related to global connection pools, however from what I can gather this seems to be related to sharing the connections between multiple apps?

Any help is much appreciated!

Upvotes: 0

Views: 880

Answers (1)

Java_User
Java_User

Reputation: 1321

Indeed seems to be too many idle connection. Try to increase the idle Connection properties or check whether you are closing all the opened connection. Please refer to this link

Upvotes: 1

Related Questions