• 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Long waiting for connect from pool

 
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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: 4116
72
Mac TypeScript Chrome Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.





 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic