Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

issue with datasource

 
mika singh
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Bartender
Posts: 1208
25
Android C++ Java Linux PHP Python
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
How are you connecting to DB? Using Tomcat JDBC connection pooling?
 
mika singh
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes karthik. I am using Tomcat JDBC connection pooling.
 
Karthik Shiraly
Bartender
Posts: 1208
25
Android C++ Java Linux PHP Python
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks dude. I will check it.
 
mika singh
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes. it is working after adding these parameters. Thanks for your help.
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64967
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
"spike learn", please check your private messages for an important administrative matter. Failure to do so will result in the removal of your account.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic