commonDb #21

Zusammengeführt
Lixfel hat 21 Commits von commonDb nach master 2022-11-22 11:34:05 +01:00 zusammengeführt
2 geänderte Dateien mit 11 neuen und 7 gelöschten Zeilen
Nur Änderungen aus Commit d6c29a25b9 werden angezeigt - Alle Commits anzeigen

Datei anzeigen

@ -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);
}
}
}

Datei anzeigen

@ -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) {