Skip to content

Commit

Permalink
DerbyController: redone experiment with getConnection
Browse files Browse the repository at this point in the history
  • Loading branch information
virgo47 committed Aug 8, 2022
1 parent 757ecaf commit 78f52e9
Showing 1 changed file with 9 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
import java.sql.DriverManager;
import java.sql.SQLException;
import java.sql.Statement;
import java.time.Instant;

import org.apache.derby.drda.NetworkServerControl;

Expand Down Expand Up @@ -70,15 +69,21 @@ public String getPassword() {
return password;
}

@SuppressWarnings("BusyWait")
public Connection getConnection() throws SQLException {
try {
return DriverManager.getConnection(jdbcUrl, "", "");
} catch (Exception e) {
while (true) {
System.err.println(Instant.now() + " Waiting for investigation of problem: " + e);
LOGGER.warn("Waiting for investigation of problem: " + e);
try {
//noinspection BusyWait
Thread.sleep(3600_000L);
Thread.sleep(10_000L); // 10 sec before retry
try {
return DriverManager.getConnection(jdbcUrl, "", "");
} catch (Exception e2) {
LOGGER.warn("Retry for connection ended with: " + e2);
}
Thread.sleep(600_000L); // 10 min
} catch (InterruptedException ex) {
throw new RuntimeException(ex);
}
Expand Down

0 comments on commit 78f52e9

Please sign in to comment.