Win a copy of Microservices in Action this week in the Web Services forum!
  • 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Bear Bibeault
  • Devaka Cooray
  • Liutauras Vilda
  • Jeanne Boyarsky
Sheriffs:
  • Knute Snortum
  • Junilu Lacar
  • paul wheaton
Saloon Keepers:
  • Ganesh Patekar
  • Frits Walraven
  • Tim Moores
  • Ron McLeod
  • Carey Brown
Bartenders:
  • Stephan van Hulst
  • salvin francis
  • Tim Holloway

JDBC connection problem  RSS feed

 
Ranch Hand
Posts: 43
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Arvind Purohit wrote:Hi All
I am trying to connect a data base. below i have given the code. I am able to connect to data base but unable to connect 2nd time if difference between 1st time and 2nd time is greater then "wait time out" of mysql data base.
I am using mysql data base. I am getting "Communications link failure" problem
wait_timeout is 10 sec (for convenience) it is 8 hour for my DB
I am giving you code


AND I am testing like


and it is giving exception like


 
Rancher
Posts: 618
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I don't know if this is your problem but you are not closing your connection, statement or result set. I see you are also eating the DatabaseInitializationException in getInstance().
 
Arvind Purohit
Ranch Hand
Posts: 43
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Tom Reilly wrote:I don't know if this is your problem but you are not closing your connection, statement or result set. I see you are also eating the DatabaseInitializationException in getInstance().


Thanks for your reply...
I am not getting what do you want to say. how do i solve this problem

Thanks
 
Tom Reilly
Rancher
Posts: 618
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You need to tell JDBC that you are done using its resources. Examples:

Statement.close()
ResultSet.close()
Connection.close()

Take a look at one of the JDBC tutorials out there. I haven't looked at one in years so cannot recommend a good one. Perhaps someone else can.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!