preparedstatement.java
来自「derby database source code.good for you.」· Java 代码 · 共 1,533 行 · 第 1/5 页
JAVA
1,533 行
} setInput(parameterIndex, x); } public void setBinaryStream(int parameterIndex, java.io.InputStream x, int length) throws SqlException { synchronized (connection_) { if (agent_.loggingEnabled()) { agent_.logWriter_.traceEntry(this, "setBinaryStream", parameterIndex, "<input stream>", length); } setBinaryStreamX(parameterIndex, x, length); } } public void setBinaryStreamX(int parameterIndex, java.io.InputStream x, int length) throws SqlException { parameterIndex = checkSetterPreconditions(parameterIndex); parameterMetaData_.clientParamtertype_[parameterIndex - 1] = java.sql.Types.BLOB; if (x == null) { setNull(parameterIndex, java.sql.Types.BLOB); return; } setInput(parameterIndex, new Blob(agent_, x, length)); } public void setAsciiStream(int parameterIndex, java.io.InputStream x, int length) throws SqlException { synchronized (connection_) { if (agent_.loggingEnabled()) { agent_.logWriter_.traceEntry(this, "setAsciiStream", parameterIndex, "<input stream>", length); } parameterIndex = checkSetterPreconditions(parameterIndex); parameterMetaData_.clientParamtertype_[parameterIndex - 1] = java.sql.Types.CLOB; if (x == null) { setNull(parameterIndex, java.sql.Types.CLOB); return; } setInput(parameterIndex, new Clob(agent_, x, "US-ASCII", length)); } } public void setUnicodeStream(int parameterIndex, java.io.InputStream x, int length) throws SqlException { synchronized (connection_) { if (agent_.loggingEnabled()) { agent_.logWriter_.traceDeprecatedEntry(this, "setUnicodeStream", parameterIndex, "<input stream>", length); } parameterIndex = checkSetterPreconditions(parameterIndex); parameterMetaData_.clientParamtertype_[parameterIndex - 1] = java.sql.Types.CLOB; if (x == null) { setNull(parameterIndex, java.sql.Types.CLOB); return; } setInput(parameterIndex, new Clob(agent_, x, "UnicodeBigUnmarked", length)); } } public void setCharacterStream(int parameterIndex, java.io.Reader x, int length) throws SqlException { synchronized (connection_) { if (agent_.loggingEnabled()) { agent_.logWriter_.traceEntry(this, "setCharacterStream", parameterIndex, x, length); } parameterIndex = checkSetterPreconditions(parameterIndex); parameterMetaData_.clientParamtertype_[parameterIndex - 1] = java.sql.Types.CLOB; if (x == null) { setNull(parameterIndex, java.sql.Types.CLOB); return; } setInput(parameterIndex, new Clob(agent_, x, length)); } } public void setBlob(int parameterIndex, java.sql.Blob x) throws SqlException { synchronized (connection_) { if (agent_.loggingEnabled()) { agent_.logWriter_.traceEntry(this, "setBlob", parameterIndex, x); } setBlobX(parameterIndex, x); } } // also used by Blob public void setBlobX(int parameterIndex, java.sql.Blob x) throws SqlException { parameterIndex = checkSetterPreconditions(parameterIndex); parameterMetaData_.clientParamtertype_[parameterIndex - 1] = java.sql.Types.BLOB; if (x == null) { setNull(parameterIndex, java.sql.Types.BLOB); return; } setInput(parameterIndex, x); } public void setClob(int parameterIndex, java.sql.Clob x) throws SqlException { synchronized (connection_) { if (agent_.loggingEnabled()) { agent_.logWriter_.traceEntry(this, "setClob", parameterIndex, x); } setClobX(parameterIndex, x); } } // also used by Clob void setClobX(int parameterIndex, java.sql.Clob x) throws SqlException { parameterIndex = checkSetterPreconditions(parameterIndex); parameterMetaData_.clientParamtertype_[parameterIndex - 1] = java.sql.Types.CLOB; if (x == null) { this.setNullX(parameterIndex, Types.CLOB); return; } setInput(parameterIndex, x); } public void setArray(int parameterIndex, java.sql.Array x) throws SqlException { synchronized (connection_) { if (agent_.loggingEnabled()) { agent_.logWriter_.traceEntry(this, "setArray", parameterIndex, x); } parameterIndex = checkSetterPreconditions(parameterIndex); throw new SqlException(agent_.logWriter_, "jdbc 2 method not yet implemented"); } } public void setRef(int parameterIndex, java.sql.Ref x) throws SqlException { synchronized (connection_) { if (agent_.loggingEnabled()) { agent_.logWriter_.traceEntry(this, "setRef", parameterIndex, x); } parameterIndex = checkSetterPreconditions(parameterIndex); throw new SqlException(agent_.logWriter_, "jdbc 2 method not yet implemented"); } } // The Java compiler uses static binding, so we must use instanceof // rather than to rely on separate setObject() methods for // each of the Java Object instance types recognized below. public void setObject(int parameterIndex, Object x) throws SqlException { synchronized (connection_) { if (agent_.loggingEnabled()) { agent_.logWriter_.traceEntry(this, "setObject", parameterIndex, x); } super.checkForClosedStatement(); if (x instanceof String) { setString(parameterIndex, (String) x); } else if (x instanceof Integer) { setInt(parameterIndex, ((Integer) x).intValue()); } else if (x instanceof Double) { setDouble(parameterIndex, ((Double) x).doubleValue()); } else if (x instanceof Float) { setFloat(parameterIndex, ((Float) x).floatValue()); } else if (x instanceof Boolean) { setBoolean(parameterIndex, ((Boolean) x).booleanValue()); } else if (x instanceof Long) { setLong(parameterIndex, ((Long) x).longValue()); } else if (x instanceof byte[]) { setBytes(parameterIndex, (byte[]) x); } else if (x instanceof java.math.BigDecimal) { setBigDecimal(parameterIndex, (java.math.BigDecimal) x); } else if (x instanceof java.sql.Date) { setDate(parameterIndex, (java.sql.Date) x); } else if (x instanceof java.sql.Time) { setTime(parameterIndex, (java.sql.Time) x); } else if (x instanceof java.sql.Timestamp) { setTimestamp(parameterIndex, (java.sql.Timestamp) x); } else if (x instanceof java.sql.Blob) { setBlob(parameterIndex, (java.sql.Blob) x); } else if (x instanceof java.sql.Clob) { setClob(parameterIndex, (java.sql.Clob) x); } else if (x instanceof java.sql.Array) { setArray(parameterIndex, (java.sql.Array) x); } else if (x instanceof java.sql.Ref) { setRef(parameterIndex, (java.sql.Ref) x); } else if (x instanceof Short) { setShort(parameterIndex, ((Short) x).shortValue()); } else if (x instanceof Byte) { setByte(parameterIndex, ((Byte) x).byteValue()); } else { checkSetterPreconditions(parameterIndex); throw new SqlException(agent_.logWriter_, "Invalid data conversion:" + " Parameter object type is invalid for requested conversion."); } } } public void setObject(int parameterIndex, Object x, int targetJdbcType) throws SqlException { synchronized (connection_) { if (agent_.loggingEnabled()) { agent_.logWriter_.traceEntry(this, "setObject", parameterIndex, x, targetJdbcType); } setObjectX(parameterIndex, x, targetJdbcType, 0); } } public void setObject(int parameterIndex, Object x, int targetJdbcType, int scale) throws SqlException { synchronized (connection_) { if (agent_.loggingEnabled()) { agent_.logWriter_.traceEntry(this, "setObject", parameterIndex, x, targetJdbcType, scale); } setObjectX(parameterIndex, x, targetJdbcType, scale); } } private void setObjectX(int parameterIndex, Object x, int targetJdbcType, int scale) throws SqlException { parameterIndex = checkSetterPreconditions(parameterIndex); checkForValidScale(scale); if (x == null) { setNull(parameterIndex, targetJdbcType); return; } // JDBC Spec specifies that conversion should occur on the client if // the targetJdbcType is specified. int inputParameterType = CrossConverters.getInputJdbcType(targetJdbcType); parameterMetaData_.clientParamtertype_[parameterIndex - 1] = inputParameterType; x = agent_.crossConverters_.setObject(inputParameterType, x); // Set to round down on setScale like embedded does in SQLDecimal try { if (targetJdbcType == java.sql.Types.DECIMAL || targetJdbcType == java.sql.Types.NUMERIC) { x = ((java.math.BigDecimal) x).setScale(scale, java.math.BigDecimal.ROUND_DOWN); } } catch (ArithmeticException ae) { // Any problems with scale should have already been caught by // checkForvalidScale throw new SqlException(agent_.logWriter_, ae.getMessage()); } setObject(parameterIndex, x); } // Since parameters are cached as objects in parameters_[], // java null may be used to represent SQL null. public void clearParameters() throws SqlException { synchronized (connection_) { if (agent_.loggingEnabled()) { agent_.logWriter_.traceEntry(this, "clearParameters"); } checkForClosedStatement(); if (parameterMetaData_ != null) { for (int i = 0; i < parameters_.length; i++) { parameters_[i] = null; } for (int i = 0; i < parameterSet_.length; i++) { parameterSet_[i] = false; } } } } public boolean execute() throws SqlException { synchronized (connection_) { if (agent_.loggingEnabled()) { agent_.logWriter_.traceEntry(this, "execute"); } boolean b = executeX(); if (agent_.loggingEnabled()) { agent_.logWriter_.traceExit(this, "execute", b); } return b; } } private boolean executeX() throws SqlException { flowExecute(executeMethod__); return resultSet_ != null; } //--------------------------JDBC 2.0----------------------------- public void addBatch() throws SqlException { synchronized (connection_) { if (agent_.loggingEnabled()) { agent_.logWriter_.traceEntry(this, "addBatch"); } checkForClosedStatement(); checkThatAllParametersAreSet(); // ASSERT: since OUT/INOUT parameters are not allowed, there should // be no problem in sharing the JDBC Wrapper object instances // since they will not be modified by the driver. // batch up the parameter values -- deep copy req'd if (parameterMetaData_ != null) { Object[] inputsClone = new Object[parameters_.length]; System.arraycopy(parameters_, 0, inputsClone, 0, parameters_.length); batch_.add(inputsClone); } else { batch_.add(null); }
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?