Home » Java » Reconnecting to database with Java Play Ebeans

Reconnecting to database with Java Play Ebeans

Posted by: admin October 26, 2017 Leave a comment

Questions:

I am using Ebeans in my Java Play application to connect to a MS SQL instance. Below is how my configs in application.conf look.

db {
 default {
  username=sa,
  password="[email protected]",
  url="jdbc:sqlserver://localhost:1433;databaseName=CentralDB",
  driver="com.microsoft.sqlserver.jdbc.SQLServerDriver"
 }
}
evolutionplugin=enable

Now when the connectivity drops in the middle its re-connecting. But when database connectivity is down at startup, it doesn’t reconnect even though database comes up later.There are no logs showing any reconnect attempts as well. What should I do in my config or code to achieve that? I am using Play 2.4.2 with E-Beans version 4.0.2. Any help would be much appreciated.

Answers: