📄 updatableresultset.java
字号:
*/ public synchronized void updateObject(int columnIndex, Object x) throws SQLException { if (!this.onInsertRow) { if (!this.doingUpdates) { this.doingUpdates = true; syncUpdate(); } this.updater.setObject(columnIndex, x); } else { this.inserter.setObject(columnIndex, x); this.thisRow[columnIndex - 1] = this.inserter.getBytesRepresentation(columnIndex - 1); } } /** * JDBC 2.0 Update a column with an Object value. The updateXXX() methods * are used to update column values in the current row, or the insert row. * The updateXXX() methods do not update the underlying database, instead * the updateRow() or insertRow() methods are called to update the * database. * * @param columnName the name of the column * @param x the new column value * @param scale For java.sql.Types.DECIMAL or java.sql.Types.NUMERIC types * this is the number of digits after the decimal. For all other * types this value will be ignored. * * @exception SQLException if a database-access error occurs */ public synchronized void updateObject(String columnName, Object x, int scale) throws SQLException { updateObject(findColumn(columnName), x); } /** * JDBC 2.0 Update a column with an Object value. The updateXXX() methods * are used to update column values in the current row, or the insert row. * The updateXXX() methods do not update the underlying database, instead * the updateRow() or insertRow() methods are called to update the * database. * * @param columnName the name of the column * @param x the new column value * * @exception SQLException if a database-access error occurs */ public synchronized void updateObject(String columnName, Object x) throws SQLException { updateObject(findColumn(columnName), x); } /** * JDBC 2.0 Update the underlying database with the new contents of the * current row. Cannot be called when on the insert row. * * @exception SQLException if a database-access error occurs, or if called * when on the insert row * @throws NotUpdatable DOCUMENT ME! */ public synchronized void updateRow() throws SQLException { if (!this.isUpdatable) { throw new NotUpdatable(); } if (this.doingUpdates) { this.updater.executeUpdate(); refreshRow(); this.doingUpdates = false; } // // fixes calling updateRow() and then doing more // updates on same row... syncUpdate(); } /** * JDBC 2.0 Update a column with a short value. The updateXXX() methods * are used to update column values in the current row, or the insert row. * The updateXXX() methods do not update the underlying database, instead * the updateRow() or insertRow() methods are called to update the * database. * * @param columnIndex the first column is 1, the second is 2, ... * @param x the new column value * * @exception SQLException if a database-access error occurs */ public synchronized void updateShort(int columnIndex, short x) throws SQLException { if (!this.onInsertRow) { if (!this.doingUpdates) { this.doingUpdates = true; syncUpdate(); } this.updater.setShort(columnIndex, x); } else { this.inserter.setShort(columnIndex, x); this.thisRow[columnIndex - 1] = this.inserter.getBytesRepresentation(columnIndex - 1); } } /** * JDBC 2.0 Update a column with a short value. The updateXXX() methods * are used to update column values in the current row, or the insert row. * The updateXXX() methods do not update the underlying database, instead * the updateRow() or insertRow() methods are called to update the * database. * * @param columnName the name of the column * @param x the new column value * * @exception SQLException if a database-access error occurs */ public synchronized void updateShort(String columnName, short x) throws SQLException { updateShort(findColumn(columnName), x); } /** * JDBC 2.0 Update a column with a String value. The updateXXX() methods * are used to update column values in the current row, or the insert row. * The updateXXX() methods do not update the underlying database, instead * the updateRow() or insertRow() methods are called to update the * database. * * @param columnIndex the first column is 1, the second is 2, ... * @param x the new column value * * @exception SQLException if a database-access error occurs */ public synchronized void updateString(int columnIndex, String x) throws SQLException { if (!this.onInsertRow) { if (!this.doingUpdates) { this.doingUpdates = true; syncUpdate(); } this.updater.setString(columnIndex, x); } else { this.inserter.setString(columnIndex, x); if (x == null) { this.thisRow[columnIndex - 1] = null; } else { if (getCharConverter() != null) { this.thisRow[columnIndex - 1] = StringUtils.getBytes(x, this.charConverter, this.charEncoding, this.connection.getServerCharacterEncoding(), this.connection.parserKnowsUnicode()); } else { this.thisRow[columnIndex - 1] = x.getBytes(); } } } } /** * JDBC 2.0 Update a column with a String value. The updateXXX() methods * are used to update column values in the current row, or the insert row. * The updateXXX() methods do not update the underlying database, instead * the updateRow() or insertRow() methods are called to update the * database. * * @param columnName the name of the column * @param x the new column value * * @exception SQLException if a database-access error occurs */ public synchronized void updateString(String columnName, String x) throws SQLException { updateString(findColumn(columnName), x); } /** * JDBC 2.0 Update a column with a Time value. The updateXXX() methods are * used to update column values in the current row, or the insert row. The * updateXXX() methods do not update the underlying database, instead the * updateRow() or insertRow() methods are called to update the database. * * @param columnIndex the first column is 1, the second is 2, ... * @param x the new column value * * @exception SQLException if a database-access error occurs */ public synchronized void updateTime(int columnIndex, java.sql.Time x) throws SQLException { if (!this.onInsertRow) { if (!this.doingUpdates) { this.doingUpdates = true; syncUpdate(); } this.updater.setTime(columnIndex, x); } else { this.inserter.setTime(columnIndex, x); this.thisRow[columnIndex - 1] = this.inserter.getBytesRepresentation(columnIndex - 1); } } /** * JDBC 2.0 Update a column with a Time value. The updateXXX() methods are * used to update column values in the current row, or the insert row. The * updateXXX() methods do not update the underlying database, instead the * updateRow() or insertRow() methods are called to update the database. * * @param columnName the name of the column * @param x the new column value * * @exception SQLException if a database-access error occurs */ public synchronized void updateTime(String columnName, java.sql.Time x) throws SQLException { updateTime(findColumn(columnName), x); } /** * JDBC 2.0 Update a column with a Timestamp value. The updateXXX() * methods are used to update column values in the current row, or the * insert row. The updateXXX() methods do not update the underlying * database, instead the updateRow() or insertRow() methods are called to * update the database. * * @param columnIndex the first column is 1, the second is 2, ... * @param x the new column value * * @exception SQLException if a database-access error occurs */ public synchronized void updateTimestamp(int columnIndex, java.sql.Timestamp x) throws SQLException { if (!this.onInsertRow) { if (!this.doingUpdates) { this.doingUpdates = true; syncUpdate(); } this.updater.setTimestamp(columnIndex, x); } else { this.inserter.setTimestamp(columnIndex, x); this.thisRow[columnIndex - 1] = this.inserter.getBytesRepresentation(columnIndex - 1); } } /** * JDBC 2.0 Update a column with a Timestamp value. The updateXXX() * methods are used to update column values in the current row, or the * insert row. The updateXXX() methods do not update the underlying * database, instead the updateRow() or insertRow() methods are called to * update the database. * * @param columnName the name of the column * @param x the new column value * * @exception SQLException if a database-access error occurs */ public synchronized void updateTimestamp(String columnName, java.sql.Timestamp x) throws SQLException { updateTimestamp(findColumn(columnName), x); } /** * Sets the concurrency type of this result set * * @param concurrencyFlag the type of concurrency that this ResultSet * should support. */ protected void setResultSetConcurrency(int concurrencyFlag) { super.setResultSetConcurrency(concurrencyFlag); // // FIXME: Issue warning when asked for updateable result set, but result set is not // updatable // //if ((concurrencyFlag == CONCUR_UPDATABLE) && !isUpdatable()) { //java.sql.SQLWarning warning = new java.sql.SQLWarning( //NotUpdatable.NOT_UPDATEABLE_MESSAGE); //} } /* (non-Javadoc) * @see com.mysql.jdbc.ResultSet#checkRowPos() */ protected void checkRowPos() throws SQLException { checkClosed(); if (!this.onInsertRow) { super.checkRowPos(); } } /** * Figure out whether or not this ResultSet is updateable, and if so, * generate the PreparedStatements to support updates. * * @throws SQLException DOCUMENT ME! * @throws NotUpdatable DOCUMENT ME! */ protected synchronized void generateStatements() throws SQLException { if (!this.isUpdatable) { this.doingUpdates = false; this.onInsertRow = false; throw new NotUpdatable(); } String quotedId = getQuotedIdChar(); if (this.fields[0].getOriginalTableName() != null) { StringBuffer tableNameBuffer = new StringBuffer(); String databaseName = this.fields[0].getDatabaseName(); if ((databaseName != null) && (databaseName.length() > 0)) { tableNameBuffer.append(quotedId); tableNameBuffer.append(databaseName); tableNameBuffer.append(quotedId); tableNameBuffer.append('.'); } this.tableOnlyName = this.fields[0].getOriginalTableName(); tableNameBuffer.append(quotedId); tableNameBuffer.append(this.tableOnlyName); tableNameBuffer.append(quotedId); this.qualifiedAndQuotedTableName = tableNameBuffer.toString(); } else { StringBuffer tableNameBuffer = new StringBuffer(); this.tableOnlyName = this.fields[0].getTableName(); tableNameBuffer.append(quotedId); tableNameBuffer.append(this.tableOnlyName); tableNameBuffer.append(quotedId); this.qualifiedAndQuotedTableName = tableNameBuffer.toString(); } this.primaryKeyIndicies = new ArrayList(); StringBuffer fieldValues = new StringBuffer(); StringBuffer keyValues = new StringBuffer(); StringBuffer columnNames = new StringBuffer(); StringBuffer insertPlaceHolders = new StringBuffer(); boolean firstTime = true; boolean keysFirstTime = true; String equalsStr = this.connection.versionMeetsMinimum(3, 23, 0) ? "<=>" : "="; for (int i = 0; i < this.fields.length; i++) { String originalCo
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -