-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathWaitDB.java
32 lines (27 loc) · 1004 Bytes
/
WaitDB.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
import java.sql.DriverManager;
public class WaitDB{
public void connect() throws Exception {
final String url = System.getenv("LIQUIBASE_URL");
final String user = System.getenv("LIQUIBASE_USERNAME");
final String password = System.getenv("LIQUIBASE_PASSWORD");
boolean connected = false;
while (!connected) {
try {
DriverManager.getConnection(url, user, password);
System.out.println("Connected to the DB server successfully.");
connected = true;
} catch (Exception e) {
System.out.println("Impossible to connect (" + e.getMessage() + "). Sleep...");
e.printStackTrace();
Thread.currentThread().sleep(2000);
}
}
}
/**
* @param args the command line arguments
*/
public static void main(String[] args) throws Exception {
WaitDB app = new WaitDB();
app.connect();
}
}