⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 jdbcpreparedstatement.java

📁 一个用java写的开源的数据库系统
💻 JAVA
📖 第 1 页 / 共 5 页
字号:
     *     * <!-- 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 setBigDecimal(int parameterIndex,                              BigDecimal x) throws SQLException {        if (Trace.TRACE) {            Trace.trace();        }        setParameter(parameterIndex,                     Column.createSQLString(x, Types.DECIMAL));    }    /**     * <!-- start generic documentation -->     * Sets the designated parameter to the given Java <code>String</code> value.     * The driver converts this     * to an SQL <code>VARCHAR</code> or <code>LONGVARCHAR</code> value     * (depending on the argument's     * size relative to the driver's limits on <code>VARCHAR</code> values)     * 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 setString(int parameterIndex, String x) throws SQLException {        if (Trace.TRACE) {            Trace.trace();        }        setParameter(parameterIndex, Column.createSQLString(x));    }    /**     * <!-- start generic documentation -->     * Sets the designated parameter to the given Java array of bytes.     * The driver converts this to an SQL <code>VARBINARY</code> or     * <code>LONGVARBINARY</code> (depending on the argument's size relative     * to the driver's limits on <code>VARBINARY</code> values) 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 setBytes(int parameterIndex, byte x[]) throws SQLException {        if (Trace.TRACE) {            Trace.trace();        }        if (x == null) {            setNull(parameterIndex);        } else {            setParameter(                parameterIndex,                Column.createSQLString(StringConverter.byteToHex(x)));        }    }    /**     * <!-- start generic documentation -->     * Sets the designated parameter to the given     * <code>java.sql.Date</code> value.  The driver converts this     * to an SQL <code>DATE</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 setDate(int parameterIndex,                        java.sql.Date x) throws SQLException {        if (Trace.TRACE) {            Trace.trace();        }        setParameter(parameterIndex, Column.createSQLString(x, Types.DATE));    }    /**     * <!-- start generic documentation -->     * Sets the designated parameter to the given <code>java.sql.Time</code>     * value. The driver converts this to an SQL <code>TIME</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 setTime(int parameterIndex,                        java.sql.Time x) throws SQLException {        if (Trace.TRACE) {            Trace.trace();        }        setParameter(parameterIndex, Column.createSQLString(x, Types.TIME));    }    /**     * <!-- start generic documentation -->     * Sets the designated parameter to the given     * <code>java.sql.Timestamp</code> value.  The driver converts this to     * an SQL <code>TIMESTAMP</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 setTimestamp(int parameterIndex,                             java.sql.Timestamp x) throws SQLException {        if (Trace.TRACE) {            Trace.trace();        }        setParameter(parameterIndex,                     Column.createSQLString(x, Types.TIMESTAMP));    }    /**     * <!-- start generic documentation -->     * Sets the designated parameter to the given input stream, which will have     * the specified number of bytes.     * When a very large ASCII value is input to a <code>LONGVARCHAR</code>     * parameter, it may be more practical to send it via a     * <code>java.io.InputStream</code>. Data will be read from the stream     * as needed until end-of-file is reached.  The JDBC driver will     * do any necessary conversion from ASCII to the database char format. <p>     *     * <b>Note:</b> This stream object can either be a standard     * Java stream object or your own subclass that implements the     * standard interface.<p>     * <!-- end generic documentation -->     * <!-- start release-specific documentation -->     * <span class="ReleaseSpecificDocumentation">     * <b>HSQLDB-Specific Information:</b> <p>     *     * This uses the default platform character encoding to convert bytes     * into characters of the String. In future this is likely to change to     * always treat the stream as ASCII.<p>     *     * Before HSQLDB 1.7.0, <code>setAsciiStream</code> and     * <code>setUnicodeStream</code> were identical.     * </span>     *     * @param parameterIndex the first parameter is 1, the second is 2, ...     * @param x the Java input stream that contains the ASCII parameter value     * @param length the number of bytes in the stream     * @exception SQLException if a database access error occurs     */    public void setAsciiStream(int parameterIndex, java.io.InputStream x,                               int length) throws SQLException {        if (Trace.TRACE) {            Trace.trace();        }        if (x == null) {            setNull(parameterIndex);        } else {            setString(parameterIndex, StringConverter.inputStreamToString(x));        }    }    /**     * <!-- start generic documentation -->     * Sets the designated parameter to the given input stream, which     * will have the specified number of bytes. A Unicode character has     * two bytes, with the first byte being the high byte, and the second     * being the low byte.     *     * When a very large Unicode value is input to a <code>LONGVARCHAR</code>     * parameter, it may be more practical to send it via a     * <code>java.io.InputStream</code> object. The data will be read from the     * stream as needed until end-of-file is reached.  The JDBC driver will     * do any necessary conversion from Unicode to the database char format.     *     * <P><B>Note:</B> This stream object can either be a standard     * Java stream object or your own subclass that implements the     * standard interface.<p>     * <!-- end generic documentation -->     *     * <!-- start release-specific documentation -->     * <span class="ReleaseSpecificDocumentation">     * <b>HSQLDB-Specific Information:</b> <p>     *     * Beginning with HSQLDB 1.7.0, this complies with JDBC3 specification.     * </span>     *     * @param parameterIndex the first parameter is 1, the second is 2, ...     * @param x a <code>java.io.InputStream</code> object that contains the     *  Unicode parameter value as two-byte Unicode characters     * @param length the number of bytes in the stream     * @exception SQLException if a database access error occurs     * @deprecated Sun does not include a reason, but presumably setCharacterStream is now prefered?     */    public void setUnicodeStream(int parameterIndex, java.io.InputStream x,                                 int length) throws SQLException {        if (Trace.TRACE) {            Trace.trace();        }        StringBuffer sb = new StringBuffer(length / 2);        try {            for (int i = 0; i < sb.length(); i++) {                int c = x.read();                if (c == -1) {                    break;                }                int c1 = x.read();                if (c1 == -1) {                    break;                }                int character = c << 8 | c1;                sb.append(character);            }        } catch (IOException e) {            throw Trace.error(Trace.TRANSFER_CORRUPTED);        }        setParameter(parameterIndex, sb.toString());    }    /**     * <!-- start generic documentation -->     * Sets the designated parameter to the given input stream, which will have     * the specified number of bytes.     * When a very large binary value is input to a <code>LONGVARBINARY</code>     * parameter, it may be more practical to send it via a     * <code>java.io.InputStream</code> object. The data will be read from the     * stream as needed until end-of-file is reached.     *     * <P><B>Note:</B> This stream object can either be a standard     * Java stream object or your own subclass that implements the     * standard interface.<p>     * <!-- end generic documentation -->     *     * <!-- start release-specific documentation -->     * <span class="ReleaseSpecificDocumentation">     * <b>HSQLDB-Specific Information:</b> <p>     *     * Up to and including HSQLDB 1.7.0, a binary stream is converted to     * a SQL string consisting of hexidecimal digits that represent the     * stream. <p>     *     * <b>Example:</b> <p>     *     * <PRE>     *    PreparedStatement ps =     *    connection.prepareStatement("SELECT * FROM t WHERE col = ?");     *    ps.setBinaryStream(1, myStream, 4);     *    ps.execute();     * </PRE>     *     * Given that the first 4 bytes of the stream are 0xff, 0xff, 0xff, 0xff,     * the above code fragement would emit the following SQL:     *     * <PRE>     *    SELECT * FROM t WHERE col = 'ffffffff'     * </PRE>     *     * Zero-length specifications result in zero bytes being read from the     * stream.  In such cases, the parameter is compiled to an empty SQL     * string.  If the length specified in the above code fragment was zero,     * the the emitted SQL would be:     *     * <PRE>     *    SELECT * FROM t WHERE col = ''     * </PRE>     *     * This behaviour <i>may</i> change in a future release.     * </span>     *     * @param parameterIndex the first parameter is 1, the second is 2, ...     * @param x the java input stream which contains the binary parameter value     * @param length the number of bytes in the stream     * @exception SQLException if a database access error occurs     */    public void setBinaryStream(int parameterIndex, java.io.InputStream x,                                int length) throws SQLException {        if (Trace.TRACE) {            Trace.trace();        }        // todo: is this correct?        // what if length=0?        // fredt@users - that seems to be fine, zero length value        byte b[] = new byte[length];

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -