事务隔离级别代码问题

时间:2015-09-04 16:45:42

标签: java oracle jdbc

我有以下java代码来设置oracle连接:

private static Connection createConnection() throws SQLException, PublishException { 
DriverManager.registerDriver(new oracle.jdbc.driver.OracleDriver()); 
String url = PublishingProperties.getDBConnString(); 
Connection conn = DriverManager.getConnection(url,PublishingProperties.getDBUser(),PublishingProperties.getDBPassword()); 
Statement stmt = conn.createStatement(); 
stmt.exec("alter session set currenct_schema=abc"); 
conn.setTransactionIsolation(Connection.TRANSACTION_SERIALIZABLE); 
conn.setAutoCommit(false); 
conn.setReadOnly(true); 
return conn; 
} 

我总是得到“ora-08177”例外。我已经阅读了一些文章,并希望将隔离级别更改为“只读”,这只能在oracle中使用。这是解决08177问题的正确方向吗?如果是,我应该摆脱以下代码:

conn.setTransactionIsolation(Connection.TRANSACTION_SERIALIZABLE); 
conn.setReadonly(true); 
从上面

并输入以下代码?

stmt.exec("ALTER SESSION SET ISOLATION_LEVEL READONLY"); 

提前谢谢!

0 个答案:

没有答案