Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Long waiting for connect from pool

 
Polo Palos
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 3913
9
Chrome Fedora Hibernate
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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....?
 
Polo Palos
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi
I don't have any errors in Tomcat's logs.

The connection, after a few seconds, is successful.

 
Jaikiran Pai
Marshal
Pie
Posts: 10444
227
IntelliJ IDE Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Polo Palos
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.





 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic