Signed-off-by: Lixfel <agga-games@gmx.de>
Dieser Commit ist enthalten in:
Ursprung
b25bf2a79c
Commit
d6c29a25b9
@ -28,7 +28,7 @@ public class ImplementationProvider {
|
|||||||
try {
|
try {
|
||||||
return (T) Class.forName(className).getDeclaredConstructor().newInstance();
|
return (T) Class.forName(className).getDeclaredConstructor().newInstance();
|
||||||
} catch (InstantiationException | IllegalAccessException | InvocationTargetException | NoSuchMethodException | ClassNotFoundException e) {
|
} 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;
|
Connection connection;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
Class.forName("org.sqlite.JDBC");
|
||||||
connection = DriverManager.getConnection("jdbc:sqlite:standalone.db");
|
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);
|
throw new SecurityException("Could not create sqlite connection", e);
|
||||||
}
|
}
|
||||||
//TODO ensure schema
|
|
||||||
|
|
||||||
conProvider = () -> connection;
|
conProvider = () -> connection;
|
||||||
}
|
}
|
||||||
@ -117,14 +118,17 @@ public class Statement implements AutoCloseable {
|
|||||||
try {
|
try {
|
||||||
result = tryWithConnection(connection, runnable, objects);
|
result = tryWithConnection(connection, runnable, objects);
|
||||||
} catch (SQLException e) {
|
} catch (SQLException e) {
|
||||||
closeConnection(connection);
|
|
||||||
connection = aquireConnection();
|
|
||||||
try {
|
try {
|
||||||
result = tryWithConnection(connection, runnable, objects);
|
if(connection.isClosed() || !connection.isValid(1)) {
|
||||||
|
closeConnection(connection);
|
||||||
|
return withConnection(runnable, objects);
|
||||||
|
}
|
||||||
} catch (SQLException ex) {
|
} catch (SQLException ex) {
|
||||||
closeConnection(connection);
|
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) {
|
synchronized (connections) {
|
||||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren