• 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

Database connection problem

 
Ranch Hand
Posts: 129
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I not able to connect to database.My code is

When i check whether datasource is null or not it is not null.But when i write
this line
con=ds.getConnection();
server gives no response the whole page is white and i not get anything.
Thanks
 
Ranch Hand
Posts: 4864
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
If you got a non-null value in your "ds" variable, and if you didn't get a class cast exception, the lookup was successful.

Can you verify that the system is "hanging" at the "ds.getConnection()" statement? Are you attempting to use the connection create a SQL statement and execute it? If so, can you verify that the statement is not getting executed?

I'd also look at what you did to define the DataSource on the app server. Verify that it is correct. Also verify that your database server is up and running.
 
amit sharma
Ranch Hand
Posts: 129
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Now i reduce the timeout value of connection to 10 sec and now i see the output i get this message
java.sql.SQLException: DBCP could not obtain an idle db connection, pool exhausted.
In my developement environment i also run many context on tomcat 5 and they are working fine.
Thanks
 
Merrill Higginson
Ranch Hand
Posts: 4864
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Increase the "maxActive" value in your DataSource definition. This message indicates that the pool size is too small.

If this doesn't work, show us the xml you used to define the DataSource.
 
amit sharma
Ranch Hand
Posts: 129
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I set the connection limit to no limit by setting maxActive to 0 as given in the tomcat site.I also set maxActive to 0 in other context .Is configurations of other context not interfere with this context.
Thanks
 
Merrill Higginson
Ranch Hand
Posts: 4864
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I'd suggest changing the maxActive to some number other than zero in both contexts. In a production environment, you don't want an unlimited number of connections. This makes you more vulnerable to a denial of service attack.
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic