commonDb #21
@ -28,7 +28,7 @@ public class ImplementationProvider {
|
||||
try {
|
||||
return (T) Class.forName(className).getDeclaredConstructor().newInstance();
|
||||
} catch (InstantiationException | IllegalAccessException | InvocationTargetException | NoSuchMethodException | ClassNotFoundException e) {
|
||||
throw new SecurityException("Could not load SQLConfigProviderImpl", e);
|
||||
throw new SecurityException("Could not load implementation", e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -64,11 +64,12 @@ public class Statement implements AutoCloseable {
|
||||
Connection connection;
|
||||
|
||||
try {
|
||||
Class.forName("org.sqlite.JDBC");
|
||||
connection = DriverManager.getConnection("jdbc:sqlite:standalone.db");
|
||||
} catch (SQLException e) {
|
||||
//TODO schema
|
||||
} catch (SQLException | ClassNotFoundException e) {
|
||||
throw new SecurityException("Could not create sqlite connection", e);
|
||||
}
|
||||
//TODO ensure schema
|
||||
|
||||
conProvider = () -> connection;
|
||||
}
|
||||
@ -117,14 +118,17 @@ public class Statement implements AutoCloseable {
|
||||
try {
|
||||
result = tryWithConnection(connection, runnable, objects);
|
||||
} catch (SQLException e) {
|
||||
closeConnection(connection);
|
||||
connection = aquireConnection();
|
||||
try {
|
||||
result = tryWithConnection(connection, runnable, objects);
|
||||
if(connection.isClosed() || !connection.isValid(1)) {
|
||||
closeConnection(connection);
|
||||
return withConnection(runnable, objects);
|
||||
}
|
||||
} catch (SQLException ex) {
|
||||
closeConnection(connection);
|
||||
throw new SecurityException("Could not execute statement", ex);
|
||||
throw new SecurityException("Could not test connection validity", ex);
|
||||
}
|
||||
|
||||
throw new SecurityException("Failing sql statement", e);
|
||||
}
|
||||
|
||||
synchronized (connections) {
|
||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren