• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Database connection problem

 
amit sharma
Ranch Hand
Posts: 129
  • Mark post as helpful
  • send pies
  • 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
 
Merrill Higginson
Ranch Hand
Posts: 4864
  • Mark post as helpful
  • send pies
  • 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
  • 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
  • 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
  • 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
  • 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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic