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

📄 serverpreparedstatement.java

📁 在资料浩瀚的互联网中
💻 JAVA
📖 第 1 页 / 共 5 页
字号:
            binding.isNull = false;            binding.isLongData = false;        }    }    /**     * Set a parameter to a java.sql.Date value.  The driver converts this to a     * SQL DATE value when it sends it to the database.     *     * @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, Date x) throws SQLException {        setDate(parameterIndex, x, null);    }    /**     * @see java.sql.PreparedStatement#setDouble(int, double)     */    public void setDouble(int parameterIndex, double x)        throws SQLException {        checkClosed();                if (!this.connection.getAllowNanAndInf() &&     			(x == Double.POSITIVE_INFINITY || x == Double.NEGATIVE_INFINITY ||    			Double.isNaN(x))) {    		throw new SQLException("'" + x +     				"' is not a valid numeric or approximate numeric value", 					SQLError.SQL_STATE_ILLEGAL_ARGUMENT);    		    	}        BindValue binding = getBinding(parameterIndex, false);        setType(binding, MysqlDefs.FIELD_TYPE_DOUBLE);        binding.value = null;        binding.doubleBinding = x;        binding.isNull = false;        binding.isLongData = false;    }    /**     * @see java.sql.PreparedStatement#setFloat(int, float)     */    public void setFloat(int parameterIndex, float x) throws SQLException {        checkClosed();        BindValue binding = getBinding(parameterIndex, false);        setType(binding, MysqlDefs.FIELD_TYPE_FLOAT);        binding.value = null;        binding.floatBinding = x;        binding.isNull = false;        binding.isLongData = false;    }    /**     * @see java.sql.PreparedStatement#setInt(int, int)     */    public void setInt(int parameterIndex, int x) throws SQLException {        checkClosed();        BindValue binding = getBinding(parameterIndex, false);        setType(binding, MysqlDefs.FIELD_TYPE_LONG);        binding.value = null;        binding.intBinding = x;        binding.isNull = false;        binding.isLongData = false;    }    /**     * @see java.sql.PreparedStatement#setLong(int, long)     */    public void setLong(int parameterIndex, long x) throws SQLException {        checkClosed();        BindValue binding = getBinding(parameterIndex, false);        setType(binding, MysqlDefs.FIELD_TYPE_LONGLONG);        binding.value = null;        binding.longBinding = x;        binding.isNull = false;        binding.isLongData = false;    }    /**     * @see java.sql.PreparedStatement#getMetaData()     */    public java.sql.ResultSetMetaData getMetaData() throws SQLException {        checkClosed();        return new ResultSetMetaData(this.resultFields);    }    /**     * @see java.sql.PreparedStatement#setNull(int, int, java.lang.String)     */    public void setNull(int parameterIndex, int sqlType, String typeName)        throws SQLException {        checkClosed();        BindValue binding = getBinding(parameterIndex, false);        //        // Don't re-set types, but use something if this        // parameter was never specified        //        if (binding.bufferType == 0) {            setType(binding, MysqlDefs.FIELD_TYPE_NULL);        }        binding.value = null;        binding.isNull = true;        binding.isLongData = false;    }    /**     * @see java.sql.PreparedStatement#setNull(int, int)     */    public void setNull(int parameterIndex, int sqlType)        throws SQLException {        checkClosed();        BindValue binding = getBinding(parameterIndex, false);        //        // Don't re-set types, but use something if this        // parameter was never specified        //        if (binding.bufferType == 0) {            setType(binding, MysqlDefs.FIELD_TYPE_NULL);        }        binding.value = null;        binding.isNull = true;        binding.isLongData = false;    }    /**     * @see java.sql.PreparedStatement#getParameterMetaData()     */    public ParameterMetaData getParameterMetaData() throws SQLException {        throw new NotImplemented();    }    /**     * @see java.sql.PreparedStatement#setRef(int, java.sql.Ref)     */    public void setRef(int i, Ref x) throws SQLException {        throw new NotImplemented();    }    /**     * @see java.sql.PreparedStatement#setShort(int, short)     */    public void setShort(int parameterIndex, short x) throws SQLException {        checkClosed();        BindValue binding = getBinding(parameterIndex, false);        setType(binding, MysqlDefs.FIELD_TYPE_SHORT);        binding.value = null;        binding.shortBinding = x;        binding.isNull = false;        binding.isLongData = false;    }    /**     * @see java.sql.PreparedStatement#setString(int, java.lang.String)     */    public void setString(int parameterIndex, String x)        throws SQLException {        checkClosed();        if (x == null) {            setNull(parameterIndex, java.sql.Types.CHAR);        } else {            BindValue binding = getBinding(parameterIndex, false);            setType(binding, this.stringTypeCode);            binding.value = x;            binding.isNull = false;            binding.isLongData = false;        }    }    /**     * Set a parameter to a java.sql.Time value.  The driver converts this to a     * SQL TIME value when it sends it to the database, using the given     * timezone.     *     * @param parameterIndex the first parameter is 1...));     * @param x the parameter value     * @param cal the timezone to use     *     * @throws SQLException if a database access error occurs     */    public void setTime(int parameterIndex, java.sql.Time x, Calendar cal)        throws SQLException {        setTimeInternal(parameterIndex, x, cal.getTimeZone(), true);    }    /**     * Set a parameter to a java.sql.Time value.     *     * @param parameterIndex the first parameter is 1...));     * @param x the parameter value     *     * @throws SQLException if a database access error occurs     */    public void setTime(int parameterIndex, java.sql.Time x)        throws SQLException {        setTimeInternal(parameterIndex, x, TimeZone.getDefault(), false);    }    /**     * Set a parameter to a java.sql.Time value.  The driver converts this to a     * SQL TIME value when it sends it to the database, using the given     * timezone.     *     * @param parameterIndex the first parameter is 1...));     * @param x the parameter value     * @param tz the timezone to use     *     * @throws SQLException if a database access error occurs     */    public void setTimeInternal(int parameterIndex, java.sql.Time x, TimeZone tz, boolean rollForward)        throws SQLException {        if (x == null) {            setNull(parameterIndex, java.sql.Types.TIME);        } else {            BindValue binding = getBinding(parameterIndex, false);            setType(binding, MysqlDefs.FIELD_TYPE_TIME);            binding.value = TimeUtil.changeTimezone(this.connection, x, tz,                    this.connection.getServerTimezoneTZ(), rollForward);            binding.isNull = false;            binding.isLongData = false;        }    }    /**     * Set a parameter to a java.sql.Timestamp value.  The driver converts this     * to a SQL TIMESTAMP value when it sends it to the database.     *     * @param parameterIndex the first parameter is 1, the second is 2, ...     * @param x the parameter value     *     * @throws SQLException if a database-access error occurs.     */    public void setTimestamp(int parameterIndex, java.sql.Timestamp x)        throws SQLException {        setTimestampInternal(parameterIndex, x, TimeZone.getDefault(), false);    }    /**     * Set a parameter to a java.sql.Timestamp value.  The driver converts this     * to a SQL TIMESTAMP value when it sends it to the database.     *     * @param parameterIndex the first parameter is 1, the second is 2, ...     * @param x the parameter value     * @param cal the timezone to use     *     * @throws SQLException if a database-access error occurs.     */    public void setTimestamp(int parameterIndex, java.sql.Timestamp x,        Calendar cal) throws SQLException {        setTimestampInternal(parameterIndex, x, cal.getTimeZone(), true);    }    /**     * @see java.sql.PreparedStatement#setURL(int, java.net.URL)     */    public void setURL(int parameterIndex, URL x) throws SQLException {        checkClosed();        setString(parameterIndex, x.toString());    }    /**     * DOCUMENT ME!     *     * @param parameterIndex DOCUMENT ME!     * @param x DOCUMENT ME!     * @param length DOCUMENT ME!     *     * @throws SQLException DOCUMENT ME!     * @throws NotImplemented DOCUMENT ME!     *     * @see java.sql.PreparedStatement#setUnicodeStream(int,     *      java.io.InputStream, int)     * @deprecated     */    public void setUnicodeStream(int parameterIndex, InputStream x, int length)        throws SQLException {        checkClosed();        throw new NotImplemented();    }    /**     * JDBC 2.0 Add a set of parameters to the batch.     *     * @exception SQLException if a database-access error occurs.     *     * @see Statement#addBatch     */    public synchronized void addBatch() throws SQLException {        checkClosed();        if (this.batchedArgs == null) {            this.batchedArgs = new ArrayList();        }        this.batchedArgs.add(new BatchedBindValues(this.parameterBindings));    }    /**     * @see java.sql.PreparedStatement#clearParameters()     */    public void clearParameters() throws SQLException {        clearParametersInternal(true);    }    /**     * @see java.sql.Statement#close()     */    public void close() throws SQLException {        realClose(true);    }    /**     * @see java.sql.Statement#executeBatch()     */    public synchronized int[] executeBatch() throws SQLException {        if (this.connection.isReadOnly()) {            throw new SQLException(Messages.getString(                    "ServerPreparedStatement.2") //$NON-NLS-1$                 +Messages.getString("ServerPreparedStatement.3"), //$NON-NLS-1$                SQLError.SQL_STATE_ILLEGAL_ARGUMENT);        }        checkClosed();        synchronized (this.connection.getMutex()) {            clearWarnings();            // Store this for later, we're going to 'swap' them out            // as we execute each batched statement...            BindValue[] oldBindValues = this.parameterBindings;            try {                int[] updateCounts = null;                if (this.batchedArgs != null) {                    int nbrCommands = this.batchedArgs.size();                    updateCounts = new int[nbrCommands];                    if (this.retrieveGeneratedKeys) {                        this.batchedGeneratedKeys = new ArrayList(nbrCommands);                    }                    for (int i = 0; i < nbrCommands; i++) {                        updateCounts[i] = -3;                    }                    SQLException sqlEx = null;                    int commandIndex = 0;                    BindValue[] previousBindValuesForBatch = null;                                        for (commandIndex = 0; commandIndex < nbrCommands;                            commandIndex++) {                        Object arg = this.batchedArgs.get(commandIndex);

⌨️ 快捷键说明

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