aspose 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 Spring in Action this week in the Spring 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: 513
    
    6
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: 513
    
    6
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: 61419
    
  67

"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]
 
wood burning stoves
 
subject: issue with datasource