preparedstatement.java
来自「derby database source code.good for you.」· Java 代码 · 共 1,533 行 · 第 1/5 页
JAVA
1,533 行
} } // Batch requires that input types are exact, we perform no input cross conversion for Batch. // If so, this is an external semantic, and should go into the release notes public int[] executeBatch() throws SqlException, BatchUpdateException { synchronized (connection_) { if (agent_.loggingEnabled()) { agent_.logWriter_.traceEntry(this, "executeBatch"); } int[] updateCounts = null; updateCounts = executeBatchX(false); if (agent_.loggingEnabled()) { agent_.logWriter_.traceExit(this, "executeBatch", updateCounts); } return updateCounts; } } public java.sql.ResultSetMetaData getMetaData() throws SqlException { synchronized (connection_) { if (agent_.loggingEnabled()) { agent_.logWriter_.traceEntry(this, "getMetaData"); } ColumnMetaData resultSetMetaData = getMetaDataX(); if (agent_.loggingEnabled()) { agent_.logWriter_.traceExit(this, "getMetaData", resultSetMetaData); } return resultSetMetaData; } } private ColumnMetaData getMetaDataX() throws SqlException { super.checkForClosedStatement(); return resultSetMetaData_; } //------------------------- JDBC 3.0 ----------------------------------- public boolean execute(String sql, int autoGeneratedKeys) throws SqlException { if (agent_.loggingEnabled()) { agent_.logWriter_.traceEntry(this, "execute", sql, autoGeneratedKeys); } throw new SqlException(agent_.logWriter_, "The method java.sql.Statement.execute (String sql, int autoGeneratedKeys) cannot be called on a " + " prepared statement instance." + " Use java.sql.PreparedStatement.execute () with no arguments."); } public boolean execute(String sql, String[] columnNames) throws SqlException { if (agent_.loggingEnabled()) { agent_.logWriter_.traceEntry(this, "execute", sql, columnNames); } throw new SqlException(agent_.logWriter_, "The method java.sql.Statement.execute (String sql, String[] columnNames) cannot be called on a " + " prepared statement instance." + " Use java.sql.PreparedStatement.execute () with no arguments."); } public boolean execute(String sql, int[] columnIndexes) throws SqlException { if (agent_.loggingEnabled()) { agent_.logWriter_.traceEntry(this, "execute", sql, columnIndexes); } throw new SqlException(agent_.logWriter_, "The method java.sql.Statement.execute (String sql, int[] columnIndexes) cannot be called on a " + " prepared statement instance." + " Use java.sql.PreparedStatement.execute () with no arguments."); } public int executeUpdate(String sql, int autoGeneratedKeys) throws SqlException { if (agent_.loggingEnabled()) { agent_.logWriter_.traceEntry(this, "executeUpdate", autoGeneratedKeys); } throw new SqlException(agent_.logWriter_, "The method java.sql.Statement.executeUpdate (String sql, int autoGeneratedKeys) cannot be called on a " + " prepared statement instance." + " Use java.sql.PreparedStatement.executeUpdate () with no arguments."); } public int executeUpdate(String sql, String[] columnNames) throws SqlException { if (agent_.loggingEnabled()) { agent_.logWriter_.traceEntry(this, "executeUpdate", columnNames); } throw new SqlException(agent_.logWriter_, "The method java.sql.Statement.executeUpdate (String sql, String[] columnNames) cannot be called on a " + " prepared statement instance." + " Use java.sql.PreparedStatement.executeUpdate () with no arguments."); } public int executeUpdate(String sql, int[] columnIndexes) throws SqlException { if (agent_.loggingEnabled()) { agent_.logWriter_.traceEntry(this, "executeUpdate", columnIndexes); } throw new SqlException(agent_.logWriter_, "The method java.sql.Statement.executeUpdate (String sql, int[] columnIndexes) cannot be called on a " + " prepared statement instance." + " Use java.sql.PreparedStatement.executeUpdate () with no arguments."); } public void setURL(int parameterIndex, java.net.URL x) throws SqlException { if (agent_.loggingEnabled()) { agent_.logWriter_.traceEntry(this, "setURL", parameterIndex, x); } throw new SqlException(agent_.logWriter_, "JDBC 3 method called - not yet supported"); } public java.sql.ParameterMetaData getParameterMetaData() throws SqlException { synchronized (connection_) { if (agent_.loggingEnabled()) { agent_.logWriter_.traceEntry(this, "getParameterMetaData"); } Object parameterMetaData = getParameterMetaDataX(); if (agent_.loggingEnabled()) { agent_.logWriter_.traceExit(this, "getParameterMetaData", parameterMetaData); } return (java.sql.ParameterMetaData) parameterMetaData; } } private ParameterMetaData getParameterMetaDataX() throws SqlException { super.checkForClosedStatement(); ParameterMetaData pm = new ParameterMetaData(parameterMetaData_ != null ? parameterMetaData_ : new ColumnMetaData(agent_.logWriter_, 0)); if (escapedProcedureCallWithResult_) { pm.escapedProcedureCallWithResult_ = true; } return pm; } // ------------------------ box car and callback methods -------------------------------- public void writeExecute(Section section, ColumnMetaData parameterMetaData, Object[] inputs, int numInputColumns, boolean outputExpected, // This is a hint to the material layer that more write commands will follow. // It is ignored by the driver in all cases except when blob data is written, // in which case this boolean is used to optimize the implementation. // Otherwise we wouldn't be able to chain after blob data is sent. // Current servers have a restriction that blobs can only be chained with blobs boolean chainedWritesFollowingSetLob) throws SqlException { materialPreparedStatement_.writeExecute_(section, parameterMetaData, inputs, numInputColumns, outputExpected, chainedWritesFollowingSetLob); } public void readExecute() throws SqlException { materialPreparedStatement_.readExecute_(); } public void writeOpenQuery(Section section, int fetchSize, int resultSetType, int numInputColumns, ColumnMetaData parameterMetaData, Object[] inputs) throws SqlException { materialPreparedStatement_.writeOpenQuery_(section, fetchSize, resultSetType, numInputColumns, parameterMetaData, inputs); } public void writeDescribeInput(Section section) throws SqlException { materialPreparedStatement_.writeDescribeInput_(section); } public void readDescribeInput() throws SqlException { materialPreparedStatement_.readDescribeInput_(); } public void completeDescribeInput(ColumnMetaData parameterMetaData, Sqlca sqlca) { int sqlcode = super.completeSqlca(sqlca); if (sqlcode < 0) { return; } parameterMetaData_ = parameterMetaData; // The following code handles the case when // sqlxParmmode is not supported, in which case server will return 0 (unknown), and // this could clobber our guessed value for sqlxParmmode. This is a problem. // We can solve this problem for Non-CALL statements, since the parmmode is always IN (1). // But what about CALL statements. If CALLs are describable, then we have no // problem, we assume server won't return unknown. // If CALLs are not describable then nothing gets clobbered because we won't // parse out extended describe, so again no problem. if (sqlMode_ != isCall__ && parameterMetaData_ != null) { for (int i = 0; i < parameterMetaData_.columns_; i++) { parameterMetaData_.sqlxParmmode_[i] = 1; // 1 means IN parameter } } if (agent_.loggingEnabled()) { agent_.logWriter_.traceParameterMetaData(this, parameterMetaData_); } } public void writeDescribeOutput(Section section) throws SqlException { materialPreparedStatement_.writeDescribeOutput_(section); } public void readDescribeOutput() throws SqlException { materialPreparedStatement_.readDescribeOutput_(); } public void completeDescribeOutput(ColumnMetaData resultSetMetaData, Sqlca sqlca) { int sqlcode = super.completeSqlca(sqlca); if (sqlcode < 0) { return; } resultSetMetaData_ = resultSetMetaData; if (agent_.loggingEnabled()) { agent_.logWriter_.traceResultSetMetaData(this, resultSetMetaData); } } void writePrepareDescribeInputOutput() throws SqlException { // Notice that sql_ is passed in since in general ad hoc sql must be passed in for unprepared statements writePrepareDescribeOutput(sql_, section_); writeDescribeInput(section_); } void readPrepareDescribeInputOutput() throws SqlException { readPrepareDescribeOutput(); readDescribeInput(); completePrepareDescribe(); } void writePrepareDescribeInput() throws SqlException { // performance will be better if we flow prepare with output enable vs. prepare then describe input for callable // Notice that sql_ is passed in since in general ad hoc sql must be passed in for unprepared statements writePrepare(sql_, section_); writeDescribeInput(section_); } void readPrepareDescribeInput() throws SqlException { readPrepare(); readDescribeInput(); completePrepareDescribe(); } void completePrepareDescribe() { if (parameterMetaData_ == null) { return; } parameters_ = expandObjectArray(parameters_, parameterMetaData_.columns_); parameterSet_ = expandBooleanArray(parameterSet_, parameterMetaData_.columns_); parameterRegistered_ = expandBooleanArray(parameterRegistered_, parameterMetaData_.columns_); } private Object[] expandObjectArray(Object[] array, int newLength) { if (array == null) { Object[] newArray = new Object[newLength]; return newArray; } if (array.length < newLength) { Object[] newArray = new Object[newLength]; System.arraycopy(array, 0, newArray, 0, array.length); return newArray; } return array; } private boolean[] expandBooleanArray(boolean[] array, int newLength) { if (array == null) { boolean[] newArray = new boolean[newLength]; return newArray; } if (array.length < newLength) { boolean[] newArray = new boolean[newLength]; System.arraycopy(array, 0, newArray, 0, array.length); return newArray; } return array; } void flowPrepareForSelectFromInsert() throws SqlException { agent_.beginWriteChain(this); writePrepareDescribeInputOutput(constructSelectFromInsertSQL(sql_), section_); agent_.flow(this); readPrepareDescribeInputOutput(); agent_.endReadChain(); } void writePrepareDescribeInputOutput(String sql, Section section) throws SqlException { // Notice that sql_ is passed in since in general ad hoc sql must be passed in for unprepared statements writePrepareDescribeOutput(sql, section); writeDescribeInput(section); } void flowPrepareDescribeInputOutput() throws SqlException { agent_.beginWriteChain(this); if (sqlMode_ == isCall__) { writePrepareDescribeInput(); agent_.flow(this); readPrepareDescribeInput();
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?