File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Tomcat and the fly likes issue with datasource Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Products » Tomcat
Bookmark "issue with datasource" Watch "issue with datasource" New topic
Author

issue with datasource

mika singh
Greenhorn

Joined: Aug 22, 2011
Posts: 9
Hi,

I have setup my application using with tomcat and it is working fine. But when I have restarted my DB machine, my application is not working. If I have restart my tomcat server then it is working fine.
may I know, how to connect to datasource automatically if my DB machine is restarted?? Is it having any specific parameter to connect datasource automatically??

Please let me know. Thanks in advance.
Karthik Shiraly
Ranch Hand

Joined: Apr 04, 2009
Posts: 491
    
    5
How are you connecting to DB? Using Tomcat JDBC connection pooling?
mika singh
Greenhorn

Joined: Aug 22, 2011
Posts: 9
Yes karthik. I am using Tomcat JDBC connection pooling.
Karthik Shiraly
Ranch Hand

Joined: Apr 04, 2009
Posts: 491
    
    5
spike learn wrote:I am using Tomcat JDBC connection pooling.

Add "testOnBorrow=true" and "validationQuery=Select 1" as attributes. Each time a connection is requested, it sends that query and if it fails with an exception, tries another connection. If all requests fail (in this case, it will), it reestablishes connections with restarted DB. Example here
mika singh
Greenhorn

Joined: Aug 22, 2011
Posts: 9
Thanks dude. I will check it.
mika singh
Greenhorn

Joined: Aug 22, 2011
Posts: 9
Yes. it is working after adding these parameters. Thanks for your help.
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60810
    
  65

"spike learn", please check your private messages for an important administrative matter. Failure to do so will result in the removal of your account.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
 
jQuery in Action, 2nd edition
 
subject: issue with datasource
 
Similar Threads
Troubleshooting Datasources In Tomcat 6
Hypersonic GUI tools
JDBC with OAS
how to connect to datasource when DB is restarted?
Latest Class files not picked up by Tomcat