我有这个 bean :
public DataSource getDatsource() throws SQLException {
OracleDataSource dataSource = new OracleDataSource();
dataSource.setUser(userName);
dataSource.setPassword(password);
dataSource.setURL(wallet);
Properties props = new Properties();
props.put("AutoCommit", false); // not working
dataSource.setConnectionProperties(props );
return dataSource;
}
我会设置数据源,就像从它生成的所有连接一样,自动提交为 false。
我该怎么做?
PS 我知道 -Doracle.jdbc.autoCommitSpecCompliant=false
并且可以工作,但我会将该属性设置为硬编码。
谢谢。
最佳答案
解决方案:
public DataSource getDefaultDataSource() throws SQLException {
OracleDataSource dataSource = new OracleDataSource();
dataSource.setUser(userName);
dataSource.setPassword(password);
dataSource.setURL(wallet);
Properties props = new Properties();
props.put("oracle.jdbc.autoCommitSpecCompliant", "false");
dataSource.setConnectionProperties(props );
return dataSource;
}
关于java - Oracle JDBC 数据源将所有连接的自动提交属性设置为 false,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55062845/