add autocommit property

This commit is contained in:
Jörg Prante 2023-08-07 18:12:23 +02:00
parent 95543ec9c6
commit 35a058abe0
3 changed files with 11 additions and 3 deletions

View file

@ -1,5 +1,5 @@
group = org.xbib
name = database
version = 1.4.0
version = 1.4.1
org.gradle.warning.mode = ALL

View file

@ -940,7 +940,7 @@ public class Pool implements BagStateListener {
}
if (writeMethod == null) {
logger.log(Level.SEVERE, "property does not exist on target: " + propName + " " + target.getClass());
throw new RuntimeException(String.format("property %s does not exist on target %s", propName, target.getClass()));
return;
}
try {
Class<?> paramClass = writeMethod.getParameterTypes()[0];
@ -965,7 +965,6 @@ public class Pool implements BagStateListener {
} catch (Exception e) {
logger.log(Level.WARNING, () ->
MessageFormat.format("failed to set property {0} on target {1}", propName, target.getClass()));
throw new RuntimeException(e);
}
}

View file

@ -21,6 +21,8 @@ public class DriverDataSource implements DataSource {
private static final String USER = "user";
private static final String AUTOCOMMIT = "autocommit";
private String jdbcUrl;
private final Properties driverProperties;
@ -108,6 +110,13 @@ public class DriverDataSource implements DataSource {
driverProperties.put(PASSWORD, driverProperties.getProperty("password", password));
}
public void setAutocommit(boolean enabled) {
String value = driverProperties.getProperty("autocommit", String.valueOf(enabled));
driverProperties.put(AUTOCOMMIT, value);
// Oracle
driverProperties.put("oracle.jdbc.autoCommitSpecCompliant", value);
}
@Override
public Connection getConnection(final String username, final String password) throws SQLException {
final Properties cloned = (Properties) driverProperties.clone();