More commonDB
Alle Prüfungen waren erfolgreich
SteamWarCI Build successful

Signed-off-by: Lixfel <agga-games@gmx.de>
Dieser Commit ist enthalten in:
Lixfel 2022-06-08 08:00:31 +02:00
Ursprung b25bf2a79c
Commit d6c29a25b9
2 geänderte Dateien mit 11 neuen und 7 gelöschten Zeilen

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