📄 connection.java
字号:
if(isolationStr.compareTo(DERBY_TRANSACTION_REPEATABLE_READ) == 0) return java.sql.Connection.TRANSACTION_REPEATABLE_READ; else if (isolationStr.compareTo(DERBY_TRANSACTION_SERIALIZABLE) == 0) return java.sql.Connection.TRANSACTION_SERIALIZABLE; else if (isolationStr.compareTo(DERBY_TRANSACTION_READ_COMMITTED) == 0) return java.sql.Connection.TRANSACTION_READ_COMMITTED; else if (isolationStr.compareTo(DERBY_TRANSACTION_READ_UNCOMMITTED) == 0) return java.sql.Connection.TRANSACTION_READ_UNCOMMITTED; else return java.sql.Connection.TRANSACTION_NONE; } public java.sql.SQLWarning getWarnings() { if (agent_.loggingEnabled()) { agent_.logWriter_.traceExit(this, "getWarnings", warnings_); } return warnings_; } synchronized public void clearWarnings() throws SqlException { if (agent_.loggingEnabled()) { agent_.logWriter_.traceEntry(this, "clearWarnings"); } clearWarningsX(); } // An untraced version of clearWarnings() public void clearWarningsX() throws SqlException { warnings_ = null; accumulated440ForMessageProcFailure_ = false; accumulated444ForMessageProcFailure_ = false; accumulatedSetReadOnlyWarning_ = false; } //====================================================================== // Advanced features: public java.sql.DatabaseMetaData getMetaData() throws SqlException { checkForClosedConnection(); if (agent_.loggingEnabled()) { agent_.logWriter_.traceExit(this, "getMetaData", databaseMetaData_); } return databaseMetaData_; } synchronized public void setReadOnly(boolean readOnly) throws SqlException { // This is a hint to the driver only, so this request is silently ignored. // PROTOCOL can only flow a set-read-only before the connection is established. if (agent_.loggingEnabled()) { agent_.logWriter_.traceEntry(this, "setReadOnly", readOnly); } checkForClosedConnection(); } public boolean isReadOnly() throws SqlException { checkForClosedConnection(); if (agent_.loggingEnabled()) { agent_.logWriter_.traceExit(this, "isReadOnly", jdbcReadOnly_); } return false; } synchronized public void setCatalog(String catalog) throws SqlException { if (agent_.loggingEnabled()) { agent_.logWriter_.traceEntry(this, "setCatalog", catalog); } checkForClosedConnection(); // Per jdbc spec: if the driver does not support catalogs, it will silently ignore this request. } public String getCatalog() throws SqlException { checkForClosedConnection(); if (agent_.loggingEnabled()) { agent_.logWriter_.traceExit(this, "getCatalog", (String) null); } return null; } //--------------------------JDBC 2.0----------------------------- synchronized public java.sql.Statement createStatement(int resultSetType, int resultSetConcurrency) throws SqlException { if (agent_.loggingEnabled()) { agent_.logWriter_.traceEntry(this, "createStatement", resultSetType, resultSetConcurrency); } Statement s = createStatementX(resultSetType, resultSetConcurrency, holdability()); if (agent_.loggingEnabled()) { agent_.logWriter_.traceExit(this, "createStatement", s); } return s; } synchronized public java.sql.PreparedStatement prepareStatement(String sql, int resultSetType, int resultSetConcurrency) throws SqlException { if (agent_.loggingEnabled()) { agent_.logWriter_.traceEntry(this, "prepareStatement", sql, resultSetType, resultSetConcurrency); } PreparedStatement ps = prepareStatementX(sql, resultSetType, resultSetConcurrency, holdability(), java.sql.Statement.NO_GENERATED_KEYS, null); if (agent_.loggingEnabled()) { agent_.logWriter_.traceExit(this, "prepareStatement", ps); } return ps; } synchronized public java.sql.CallableStatement prepareCall(String sql, int resultSetType, int resultSetConcurrency) throws SqlException { if (agent_.loggingEnabled()) { agent_.logWriter_.traceEntry(this, "prepareCall", sql, resultSetType, resultSetConcurrency); } CallableStatement cs = prepareCallX(sql, resultSetType, resultSetConcurrency, holdability()); if (agent_.loggingEnabled()) { agent_.logWriter_.traceExit(this, "prepareCall", cs); } return cs; } synchronized public CallableStatement prepareMessageProc(String sql) throws SqlException { checkForClosedConnection(); CallableStatement cs = prepareCallX(sql, java.sql.ResultSet.TYPE_FORWARD_ONLY, java.sql.ResultSet.CONCUR_READ_ONLY, holdability()); return cs; } // Per jdbc spec, when a result set type is unsupported, we downgrade and // issue a warning rather than to throw an exception. private int downgradeResultSetType(int resultSetType) { if (resultSetType == java.sql.ResultSet.TYPE_SCROLL_SENSITIVE) { accumulateWarning(new SqlWarning(agent_.logWriter_, "Scroll sensitive result sets are not supported by server; remapping to forward-only cursor")); return java.sql.ResultSet.TYPE_SCROLL_INSENSITIVE; } return resultSetType; } // Per jdbc spec, when a result set concurrency is unsupported, we downgrade and // issue a warning rather than to throw an exception. private int downgradeResultSetConcurrency(int resultSetConcurrency, int resultSetType) { if (resultSetConcurrency == java.sql.ResultSet.CONCUR_UPDATABLE && resultSetType == java.sql.ResultSet.TYPE_SCROLL_INSENSITIVE) { accumulateWarning(new SqlWarning(agent_.logWriter_, "Insensitive updatable result sets are not supported by server; remapping to insensitive read-only cursor")); return java.sql.ResultSet.CONCUR_READ_ONLY; } return resultSetConcurrency; } public java.util.Map getTypeMap() throws SqlException { if (agent_.loggingEnabled()) { agent_.logWriter_.traceEntry(this, "getTypeMap"); } checkForClosedConnection(); java.util.Map map = new java.util.HashMap(); if (agent_.loggingEnabled()) { agent_.logWriter_.traceExit(this, "getTypeMap", map); } return map; } synchronized public void setTypeMap(java.util.Map map) throws SqlException { if (agent_.loggingEnabled()) { agent_.logWriter_.traceEntry(this, "setTypeMap", map); } checkForClosedConnection(); throw new SqlException(agent_.logWriter_, "Connection.setTypeMap is not supported"); } //--------------------------JDBC 3.0----------------------------- synchronized public void setHoldability(int holdability) throws SqlException { if (agent_.loggingEnabled()) { agent_.logWriter_.traceEntry(this, "setHoldability", holdability); } checkForClosedConnection(); // In an XA global transaction do not allow the // holdability to be set to hold cursors across // commits, as the engine does not support it. if (this.isXAConnection_ && this.xaState_ == XA_T1_ASSOCIATED) { if (holdability == ClientDataSource.HOLD_CURSORS_OVER_COMMIT) throw new SqlException(agent_.logWriter_, "Cannot set holdability ResultSet.HOLD_CURSORS_OVER_COMMIT for a global transaction.", "XJ05C"); } this.holdability = holdability; } public int getHoldability() throws SqlException { checkForClosedConnection(); if (agent_.loggingEnabled()) { agent_.logWriter_.traceExit(this, "getHoldability", holdability()); } return holdability(); } public int dncGeneratedSavepointId_; // generated name used internally for unnamed savepoints public static final String dncGeneratedSavepointNamePrefix__ = "DNC_GENENERATED_NAME_"; synchronized public java.sql.Savepoint setSavepoint() throws SqlException { if (agent_.loggingEnabled()) { agent_.logWriter_.traceEntry(this, "setSavepoint"); } checkForClosedConnection(); if (autoCommit_) // Throw exception if auto-commit is on { throw new SqlException(agent_.logWriter_, "Cannot set savepoint when in auto-commit mode."); } // create an un-named savepoint. if ((++dncGeneratedSavepointId_) < 0) { dncGeneratedSavepointId_ = 1; // restart from 1 when overflow. } Object s = setSavepointX(new Savepoint(agent_, dncGeneratedSavepointId_)); return (java.sql.Savepoint) s; } synchronized public java.sql.Savepoint setSavepoint(String name) throws SqlException { if (agent_.loggingEnabled()) { agent_.logWriter_.traceEntry(this, "setSavepoint", name); } checkForClosedConnection(); if (name == null) // Throw exception if savepoint name is null { throw new SqlException(agent_.logWriter_, "Named savepoint needs a none-null name."); } else if (autoCommit_) // Throw exception if auto-commit is on { throw new SqlException(agent_.logWriter_, "Cannot set savepoint when in auto-commit mode."); } // create a named savepoint. Object s = setSavepointX(new Savepoint(agent_, name)); return (java.sql.Savepoint) s; } private Savepoint setSavepointX(Savepoint savepoint) throws SqlException { // Construct and flow a savepoint statement to server. Statement stmt = null; try { stmt = (Statement) createStatementX(java.sql.ResultSet.TYPE_FORWARD_ONLY, java.sql.ResultSet.CONCUR_READ_ONLY, holdability()); String savepointName; try { savepointName = savepoint.getSavepointName(); } catch (SqlException e) { // generate the name for an un-named savepoint. savepointName = dncGeneratedSavepointNamePrefix__ + savepoint.getSavepointId(); } String sql = "SAVEPOINT \"" + savepointName + "\" ON ROLLBACK RETAIN CURSORS"; stmt.executeX(sql); } finally { if (stmt != null) { try { stmt.closeX(); } catch (SqlException doNothing) { } } } return savepoint; } synchronized public void rollback(java.sql.Savepoint savepoint) throws SqlException { int saveXaState = xaState_; if (agent_.loggingEnabled()) { agent_.logWriter_.traceEntry(this, "rollback", savepoint); } checkForClosedConnection(); if (savepoint == null) // Throw exception if savepoint is null { throw new SqlException(agent_.logWriter_, "Cannot rollback to a null savepoint."); } else if (autoCommit_) // Throw exception if auto-commit is on { throw new SqlException(agent_.logWriter_, "Cannot rollback to a savepoint when in auto-commit mode."); } // Only allow to rollback to a savepoint from the connection that create the savepoint. try { if (this != ((Savepoint) savepoint).agent_.connection_) { throw new SqlException(agent_.logWriter_, "Rollback to a savepoint not created by this connection."); } } catch (java.lang.ClassCastException e) { // savepoint is not an instance of am.Savepoint throw new SqlException(agent_.logWriter_, "Rollback to a savepoint not created by this connection."); } // Construct and flow a savepoint rollback statement to server. Statement stmt = null; try { stmt = createStatementX(java.sql.ResultSet.TYPE_FORWARD_ONLY, java.sql.ResultSet.CONCUR_READ_ONLY, holdability()); String savepointName; try { savepointName = ((Savepoint) savepoint).getSavepointName(); } catch (SqlException e) { // generate the name for an un-named savepoint. savepointName = dncGeneratedSavepointNamePrefix__ + ((Savepoint) savepoint).getSavepointId(); } String sql = "ROLLBACK TO SAVEPOINT \"" + savepointName + "\""; stmt.executeX(sql); } finally { if (stmt != null) { try { stmt.closeX(); } catch (SqlException doNothing) { }
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -