【Java开源代码栏目提醒】:本文主要为网学会员提供UpdatableResultSet.java,希望对需要UpdatableResultSet.java网友有所帮助,学习一下!
/*
Copyright (C) 2002-2004 MySQL AB
This program is free software; you can redistribute it and/or modify
it under the terms of version 2 of the GNU General Public License as
published by the Free Software Foundation.
There are special exceptions to the terms and conditions of the GPL
as it is applied to this software. View the full text of the
exception in file EXCEPTIONS-CONNECTOR-J in the directory of this
software distribution.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
package com.mysql.jdbc;
import com.mysql.jdbc.profiler.ProfileEventSink;
import com.mysql.jdbc.profiler.ProfilerEvent;
import java.math.BigDecimal;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
/**
* A result set that is updatable.
*
* @author Mark Matthews
*/
public class UpdatableResultSet extends ResultSet {
/** Marker for 'stream' data when doing INSERT rows */
private final static byte[] STREAM_DATA_MARKER = "** STREAM DATA **" //$NON-NLS-1$
.getBytes();
private SingleByteCharsetConverter charConverter;
private String charEncoding;
/** What is the default value for the column? */
private byte[][] defaultColumnValue;
/** PreparedStatement used to delete data */
private com.my
sql.jdbc.PreparedStatement deleter = null;
private String deleteSQL = null;
private boolean initializedCharConverter = false;
/** PreparedStatement used to insert data */
private com.
mysql.jdbc.PreparedStatement inserter = null;
private String insertSQL = null;
/** Is this result set updateable? */
private boolean isUpdatable = false;
/** List of primary keys */
private List primaryKeyIndicies = null;
private String qualifiedAndQuotedTableName;
private String quotedIdChar = null;
/** PreparedStatement used to refresh data */
private com.mysql.jdbc.PreparedStatement refresher;
private String refreshSQL = null;
/** The binary data for the 'current' row */
private byte[][] savedCurrentRow;
private String tableOnlyName;
/** PreparedStatement used to delete data */
private com.mysql.jdbc.PreparedStatement updater = null;
/** SQL for in-place modifcation */
private String updateSQL = null;
/**
* Create a result set for an executeUpdate statement.
*
* @param updateCount
* the number of rows affected by the update
* @param updateID
* the autoincrement value (if any)
* @param conn
* DOCUMENT ME!
* @param creatorStmt
* DOCUMENT ME!
*
* @throws SQLException
* DOCUMENT ME!
*/
public UpdatableResultSet(long updateCount, long updateID, Connection conn,
Statement creatorStmt) throws SQLException {
super(updateCount, updateID, conn, creatorStmt);
checkUpdatability();
}
/**
* Creates a new ResultSet object.
*
* @param catalog
* the database in use when we were created
* @param fields
* an array of Field objects (basically, the ResultSet MetaData)
* @param tuples
* actual row data
* @param conn
* the Connection that created us.
* @param creatorStmt
* DOCUMENT ME!
*
* @throws SQLException
* DOCUMENT ME!
*/
public UpdatableResultSet(String catalog, Field[] fields, RowData tuples,
Connection conn, Statement creatorStmt) throws SQLException {
super(catalog, fields, tuples, conn, creatorStmt);
checkUpdatability();
}
/**
* JDBC 2.0
*
* <p>
* Move to an absolute row number in the result set.
* </p>
*
* <p>
* If row is positive, moves to an absolute row with respect to the
* beginning of the result set. The first row is row 1, the second is row 2,
* etc.
* </p>
*
* <p>
* If row is negative, moves to an absolute row position with respect to the
* end of result set. For example, calling absolute(-1) positions the cursor
* on the last row, absolute(-2) indicates the next-to-last row, etc.
* </p>
*
* <p>
* An attempt to position the cursor beyond the first/last row in the result
* set, leaves the cursor before/after the first/last row, respectively.
* </p>
*
* <p>
* Note: Calling absolute(1) is the same as calling first(). Calling
* absolute(-1) is the same as calling last().
* </p>
*
* @param row