Win a copy of The Business Blockchain this week in the Cloud forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Beginer question: What to do if you get JDBCConnectionException

 
Andrei Antonescu
Ranch Hand
Posts: 75
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello friends,

I have a beginer question about Hibernate.
Can you please tell me what to do if I get a JDBCConnectionException because my database connection is too slow and Hibernate considers that the query cannot be executed (Or that's what I think it's happening).
Should I set the timeout in Hibernate to a bigger value? Or should I try to recreate the SessionFactory and the session and then reexecute the query in a loop until it is successful? By the way, I understand that the SessionFactory must be recreated after such an error.

I cannot test anything because the exception happend at random (big) intervals.

Thanks in advance
 
Vijitha Kumara
Bartender
Pie
Posts: 3930
21
Chrome Fedora Hibernate
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Have you checked what's causing the error (too many connections on the DB or ...) in the first place? If this happen frequently in production that may be a big issue.
 
Andrei Antonescu
Ranch Hand
Posts: 75
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello,

Thanks the for reply. I don't know exactly what's the cause because everything looks fine. Too many connections is unlikely. I am thinking that the connection between the DB and web App is too slow, and Hibernate considers it can't connect.

 
Vijitha Kumara
Bartender
Pie
Posts: 3930
21
Chrome Fedora Hibernate
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Andrei Antonescu wrote: ...Too many connections is unlikely...

If you are so sure about it then there might be a network issue? BTW, is this a local DB?
 
Andrei Antonescu
Ranch Hand
Posts: 75
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It is a remote DB and only one user uses it. It can't be a network problem because other simillar projects (developed on the same framework) use the same remote server (but a different DB).
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic