This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes Tomcat and the fly likes Long waiting for connect from pool Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Products » Tomcat
Bookmark "Long waiting for connect from pool" Watch "Long waiting for connect from pool" New topic
Author

Long waiting for connect from pool

Polo Palos
Greenhorn

Joined: Mar 17, 2006
Posts: 12
Hello,
I have problem with get connection from pool.

I try to connect to DB2 (on iSeries).
Firstly, i connect by service - there is no problem.


Next, I connect to DB2 by get connection from pool,
like this.


I have problem with this: datasource.getConnection();
Practically, I always wait for get connection a few minutes.

This is my context:
Vijitha Kumara
Bartender

Joined: Mar 24, 2008
Posts: 3816

Practically, I always wait for get connection a few minutes.

Can you elaborate this more....?
I'm not sure about anything specific to DB2 here but have you checked the logs whether Tomcat initialized the connection pool, any errors etc....?


SCJP 5 | SCWCD 5
[How to ask questions] [Twitter]
Polo Palos
Greenhorn

Joined: Mar 17, 2006
Posts: 12
Hi
I don't have any errors in Tomcat's logs.

The connection, after a few seconds, is successful.

Jaikiran Pai
Marshal

Joined: Jul 20, 2005
Posts: 9913
    
158

Practically, I always wait for get connection a few minutes.


How did you measure that? And is the connection successfully returned after that time? Or does it fail to get the connection? Where is the DB server located?

Also, I see that you have this in your datasource configuration:



As per the docs:

validationQuery - SQL query that can be used by the pool to validate connections before they are returned to the application. If specified, this query MUST be an SQL SELECT statement that returns at least one row.


So it really depends on how many rows your test.testl table contains. If it has many rows, then it might affect the performance. You might want to change that query to perform better.

[My Blog] [JavaRanch Journal]
Polo Palos
Greenhorn

Joined: Mar 17, 2006
Posts: 12
I measure connect like this:

log.warn("After (DataSource)ctx.lookup"); //log datetime before connect
Connection conn = datasource.getConnection();//here is problem - I wait, wait, wait
log.warn("After datasource.getConnection()"); //log datetime after connect

After a few minutes the connection is successful. I don't have any fails.

DB server locate on the same network.

So it really depends on how many rows your test.testl table contains

This table (test.test1) contains just one row.

But is strange for me that
when I stop in browser then connection,
and after that I connect second time - I get the connection immediately.





 
 
subject: Long waiting for connect from pool
 
Similar Threads
how get datasource object in sun java studio creater
How To Access Objects Returned From A Helper/Utility Class?
Create ConnectionPool in ServletContextListener
What Exception if database down
Must Restart Tomcat to Aquire A Connection From The Pool