📄 jdbcpreparedstatement.java
字号:
/** * <!-- start generic documentation --> * Sets escape processing on or off. <p> * <!-- end generic documentation --> * * <!-- start release-specific documentation --> * <span class="ReleaseSpecificDocumentation"> * <b>HSQLDB-Specific Information:</b> <p> * * HSQLDB 1.7.0 follows the standard behaviour by overriding the same * method in jdbcStatement class. <p> * * Calling this method will have no effect. * * </span> * <!-- end release-specific documentation --> * * @param enable <code>true</code> to enable escape processing; * <code>false</code> to disable it * @exception SQLException if a database access error occurs */// fredt@users 20020428 - patch 1.7.0 - method orerrides the one in jdbcStatement public void setEscapeProcessing(boolean enable) throws SQLException { if (Trace.TRACE) { Trace.trace(); } checkClosed(); // do not change the bEscapeProcessing // bEscapeProcessing = enable; } /** * <!-- start generic documentation --> * Executes the SQL query in this <code>PreparedStatement</code> object * and returns the <code>ResultSet</code> object generated by the query.<p> * <!-- end generic documentation --> * * <!-- start release-specific documentation --> * <span class="ReleaseSpecificDocumentation"> * </span> * * @return a <code>ResultSet</code> object that contains the data produced * by the query; never <code>null</code> * @exception SQLException if a database access error occurs or the SQL * statement does not return a <code>ResultSet</code> object */ public ResultSet executeQuery() throws SQLException { if (Trace.TRACE) { Trace.trace(); } return super.executeQuery(build()); } /** * <!-- start generic documentation --> * Executes the SQL statement in this <code>PreparedStatement</code> * object, which must be an SQL <code>INSERT</code>, * <code>UPDATE</code> or <code>DELETE</code> statement; or an SQL * statement that returns nothing, such as a DDL statement.<p> * <!-- end generic documentation --> * * <!-- start release-specific documentation --> * <span class="ReleaseSpecificDocumentation"> * </span> * * @return either (1) the row count for <code>INSERT</code>, * <code>UPDATE</code>, or <code>DELETE</code> * statements or (2) 0 for SQL statements that * return nothing * @exception SQLException if a database access error occurs or the SQL * statement returns a <code>ResultSet</code> object */ public int executeUpdate() throws SQLException { if (Trace.TRACE) { Trace.trace(); } return super.executeUpdate(build()); } /** * <!-- start generic documentation --> * Sets the designated parameter to SQL <code>NULL</code>. <p> * * <B>Note:</B> You must specify the parameter's SQL type.<p> * <!-- end generic documentation --> * * <!-- start release-specific documentation --> * <span class="ReleaseSpecificDocumentation"> * </span> * * @param parameterIndex the first parameter is 1, the second is 2, ... * @param sqlType the SQL type code defined in <code>java.sql.Types</code> * @exception SQLException if a database access error occurs */ public void setNull(int parameterIndex, int sqlType) throws SQLException { if (Trace.TRACE) { Trace.trace(); } setNull(parameterIndex); } /** * <!-- start generic documentation --> * Sets the designated parameter to the given Java <code>boolean</code> * value. The driver converts this to an SQL <code>BIT</code> value * when it sends it to the database.<p> * <!-- end generic documentation --> * * <!-- start release-specific documentation --> * <span class="ReleaseSpecificDocumentation"> * </span> * * @param parameterIndex the first parameter is 1, the second is 2, ... * @param x the parameter value * @exception SQLException if a database access error occurs */ public void setBoolean(int parameterIndex, boolean x) throws SQLException { if (Trace.TRACE) { Trace.trace(); } setParameter(parameterIndex, x ? "TRUE" : "FALSE"); } /** * <!-- start generic documentation --> * Sets the designated parameter to the given Java <code>byte</code> value. * The driver converts this to an SQL <code>TINYINT</code> value when * it sends it to the database.<p> * <!-- end generic documentation --> * * <!-- start release-specific documentation --> * <span class="ReleaseSpecificDocumentation"> * </span> * * @param parameterIndex the first parameter is 1, the second is 2, ... * @param x the parameter value * @exception SQLException if a database access error occurs */ public void setByte(int parameterIndex, byte x) throws SQLException { if (Trace.TRACE) { Trace.trace(); } setParameter(parameterIndex, String.valueOf(x)); } /** * <!-- start generic documentation --> * Sets the designated parameter to the given Java <code>short</code> * value. The driver converts this to an SQL <code>SMALLINT</code> * value when it sends it to the database.<p> * <!-- end generic documentation --> * * <!-- start release-specific documentation --> * <span class="ReleaseSpecificDocumentation"> * </span> * * @param parameterIndex the first parameter is 1, the second is 2, ... * @param x the parameter value * @exception SQLException if a database access error occurs */ public void setShort(int parameterIndex, short x) throws SQLException { if (Trace.TRACE) { Trace.trace(); } setParameter(parameterIndex, String.valueOf(x)); } /** * <!-- start generic documentation --> * Sets the designated parameter to the given Java <code>int</code> value. * The driver converts this to an SQL <code>INTEGER</code> value when * it sends it to the database.<p> * <!-- end generic documentation --> * * <!-- start release-specific documentation --> * <span class="ReleaseSpecificDocumentation"> * </span> * * @param parameterIndex the first parameter is 1, the second is 2, ... * @param x the parameter value * @exception SQLException if a database access error occurs */ public void setInt(int parameterIndex, int x) throws SQLException { if (Trace.TRACE) { Trace.trace(); } setParameter(parameterIndex, String.valueOf(x)); } /** * <!-- start generic documentation --> * Sets the designated parameter to the given Java <code>long</code> value. * The driver converts this to an SQL <code>BIGINT</code> value when * it sends it to the database.<p> * <!-- end generic documentation --> * * <!-- start release-specific documentation --> * <span class="ReleaseSpecificDocumentation"> * </span> * * @param parameterIndex the first parameter is 1, the second is 2, ... * @param x the parameter value * @exception SQLException if a database access error occurs */ public void setLong(int parameterIndex, long x) throws SQLException { if (Trace.TRACE) { Trace.trace(); } setParameter(parameterIndex, String.valueOf(x)); } /** * <!-- start generic documentation --> * Sets the designated parameter to the given Java <code>float</code> value. * The driver converts this to an SQL <code>FLOAT</code> value when * it sends it to the database.<p> * <!-- end generic documentation --> * * <!-- start release-specific documentation --> * <span class="ReleaseSpecificDocumentation"> * <b>HSQLDB-Specific Information:</b> <p> * * Up to 1.6.1, HSQLDB did not handle Java positive/negative Infinity or * NaN <code>float</code> values properly. With 1.7.0, * these values are converted to SQL <code>NULL</code>. With 1.7.1 these * values are sent to the database. * </span> * * @param parameterIndex the first parameter is 1, the second is 2, ... * @param x the parameter value * @exception SQLException if a database access error occurs */// fredt@users 20020325 - patch 448691 NaN by fredt// fredt@users 20021013 - patch 1.7.1 - NaN and infinity preserved public void setFloat(int parameterIndex, float x) throws SQLException { if (Trace.TRACE) { Trace.trace(); } setParameter(parameterIndex, Column.createSQLString(x));/* if (Float.isInfinite(x) || Float.isNaN(x)) { setNull(parameterIndex); } else { String s = String.valueOf(x); // ensure the engine treats the value as a DOUBLE, not DECIMAL if (s.indexOf('E') < 0) { s = s.concat("E0"); } setParameter(parameterIndex, s); }*/ } /** * <!-- start generic documentation --> * Sets the designated parameter to the given Java <code>double</code> value. * The driver converts this to an SQL <code>DOUBLE</code> value when it * sends it to the database.<p> * <!-- end generic documentation --> * * <!-- start release-specific documentation --> * <span class="ReleaseSpecificDocumentation"> * <b>HSQLDB-Specific Information:</b> <p> * * Up to 1.6.1, HSQLDB did not handle Java positive/negative Infinity or * NaN <code>float</code> values properly. With 1.7.0, * these values are converted to SQL <code>NULL</code>. With 1.7.1 these * values are sent to the database. * </span> * * @param parameterIndex the first parameter is 1, the second is 2, ... * @param x the parameter value * @exception SQLException if a database access error occurs */// fredt@users 20020325 - patch 448691 NaN by fredt// fredt@users 20021013 - patch 1.7.1 - NaN and infinity preserved public void setDouble(int parameterIndex, double x) throws SQLException { if (Trace.TRACE) { Trace.trace(); } setParameter(parameterIndex, Column.createSQLString(x));/* if (Double.isInfinite(x) || Double.isNaN(x)) { setNull(parameterIndex); } else { String s = String.valueOf(x); // ensure the engine treats the value as a DOUBLE, not DECIMAL if (s.indexOf('E') < 0) { s = s.concat("E0"); } setParameter(parameterIndex, s); }*/ } /** * <!-- start generic documentation --> * Sets the designated parameter to the given * <code>java.math.BigDecimal</code> value. * The driver converts this to an SQL <code>NUMERIC</code> value when * it sends it to the database.<p> * <!-- end generic documentation -->
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -