public void setTransactionIsolation(int level) throws SQLException { if ((level != Connection.TRANSACTION_NONE) && (level != Connection.TRANSACTION_READ_COMMITTED) && (level != Connection.TRANSACTION_READ_UNCOMMITTED) && (level != Connection.TRANSACTION_REPEATABLE_READ) && (level != Connection.TRANSACTION_SERIALIZABLE)) { throw new SQLException("Invalid transaction isolation set. Must " + "be either " + "Connection.TRANSACTION_NONE or " + "Connection.TRANSACTION_READ_UNCOMMITTED or " + "Connection.TRANSACTION_READ_COMMITTED or " + "Connection.RRANSACTION_REPEATABLE_READ or " + "Connection.TRANSACTION_SERIALIZABLE"); } this.isolation = level; }
时间: 2024-02-14 09:36:00 浏览: 151
这是一个Java中的数据库连接池中的代码,用于设置连接的事务隔离级别。其中,方法参数level代表事务隔离级别,如果level不是定义好的五种隔离级别之一,将会抛出SQLException异常,提示"Invalid transaction isolation set. Must be either Connection.TRANSACTION_NONE or Connection.TRANSACTION_READ_UNCOMMITTED or Connection.TRANSACTION_READ_COMMITTED or Connection.RRANSACTION_REPEATABLE_READ or Connection.TRANSACTION_SERIALIZABLE"。如果level是有效的,那么会将当前连接的隔离级别设置为level。
阅读全文