【问题标题】:Oracle JDBC Datasource set auto commit property to false to all connectionsOracle JDBC 数据源将所有连接的自动提交属性设置为 false
【发布时间】:2019-07-30 11:08:37
【问题描述】:

我有这个豆子:

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 并且可以工作,但我会将属性设置为硬编码。

谢谢。

【问题讨论】:

  • 你试过dataSource.SetAutoCommit(false)吗?
  • OracleDatasource 如果没有 setautocommit。连接有它
  • 为什么你认为Oracle数据源有一个叫做AutoCommit的属性?无论如何,如果-Doracle.jdbc.autoCommitSpecCompliant=false 有效,您是否尝试过使用props.put("oracle.jdbc.autoCommitSpecCompliant", "false")

标签: java oracle jdbc datasource


【解决方案1】:

解决方案:

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

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2016-04-04
    • 2014-10-01
    • 1970-01-01
    • 1970-01-01
    • 2013-12-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多