• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Bear Bibeault
  • Junilu Lacar
Sheriffs:
  • Jeanne Boyarsky
  • Tim Cooke
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • salvin francis
  • Frits Walraven
Bartenders:
  • Scott Selikoff
  • Piet Souris
  • Carey Brown

Long waiting for connect from pool

 
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:
 
Bartender
Posts: 4107
72
Hibernate Fedora Chrome
  • 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.

 
Sheriff
Posts: 10445
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.





 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
    Bookmark Topic Watch Topic
  • New Topic