?? jdbc4updatableresultset.java
字號:
/*
Copyright (C) 2002-2007 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 java.io.InputStream;
import java.io.Reader;
import java.io.UnsupportedEncodingException;
import java.sql.NClob;
import java.sql.RowId;
import java.sql.SQLException;
import java.sql.SQLXML;
import com.mysql.jdbc.Connection;
import com.mysql.jdbc.Field;
import com.mysql.jdbc.NotUpdatable;
import com.mysql.jdbc.RowData;
import com.mysql.jdbc.Statement;
import com.mysql.jdbc.StringUtils;
import com.mysql.jdbc.UpdatableResultSet;
import com.mysql.jdbc.exceptions.NotYetImplementedException;
public class JDBC4UpdatableResultSet extends UpdatableResultSet {
public JDBC4UpdatableResultSet(String catalog, Field[] fields, RowData tuples,
ConnectionImpl conn, StatementImpl creatorStmt) throws SQLException {
super(catalog, fields, tuples, conn, creatorStmt);
}
public void updateAsciiStream(int columnIndex, InputStream x) throws SQLException {
throw new NotUpdatable();
}
public void updateAsciiStream(int columnIndex, InputStream x, long length) throws SQLException {
throw new NotUpdatable();
}
public void updateBinaryStream(int columnIndex, InputStream x) throws SQLException {
throw new NotUpdatable();
}
public void updateBinaryStream(int columnIndex, InputStream x, long length) throws SQLException {
throw new NotUpdatable();
}
public void updateBlob(int columnIndex, InputStream inputStream) throws SQLException {
throw new NotUpdatable();
}
public void updateBlob(int columnIndex, InputStream inputStream, long length) throws SQLException {
throw new NotUpdatable();
}
public void updateCharacterStream(int columnIndex, Reader x) throws SQLException {
throw new NotUpdatable();
}
public void updateCharacterStream(int columnIndex, Reader x, long length) throws SQLException {
throw new NotUpdatable();
}
public void updateClob(int columnIndex, Reader reader) throws SQLException {
throw new NotUpdatable();
}
public void updateClob(int columnIndex, Reader reader, long length) throws SQLException {
throw new NotUpdatable();
}
public void updateNCharacterStream(int columnIndex, Reader x) throws SQLException {
throw new NotUpdatable();
}
public void updateNCharacterStream(int columnIndex, Reader x, long length) throws SQLException {
updateNCharacterStream(columnIndex, x, (int) length);
}
public void updateNClob(int columnIndex, Reader reader) throws SQLException {
throw new NotUpdatable();
}
public void updateNClob(int columnIndex, Reader reader, long length) throws SQLException {
throw new NotUpdatable();
}
public void updateSQLXML(int columnIndex, SQLXML xmlObject) throws SQLException {
throw new NotUpdatable();
}
public void updateRowId(int columnIndex, RowId x) throws SQLException {
throw new NotUpdatable();
}
public void updateAsciiStream(String columnLabel, InputStream x) throws SQLException {
updateAsciiStream(findColumn(columnLabel), x);
}
public void updateAsciiStream(String columnLabel, InputStream x, long length) throws SQLException {
updateAsciiStream(findColumn(columnLabel), x, length);
}
public void updateBinaryStream(String columnLabel, InputStream x) throws SQLException {
updateBinaryStream(findColumn(columnLabel), x);
}
public void updateBinaryStream(String columnLabel, InputStream x, long length) throws SQLException {
updateBinaryStream(findColumn(columnLabel), x, length);
}
public void updateBlob(String columnLabel, InputStream inputStream) throws SQLException {
updateBlob(findColumn(columnLabel), inputStream);
}
public void updateBlob(String columnLabel, InputStream inputStream, long length) throws SQLException {
updateBlob(findColumn(columnLabel), inputStream, length);
}
public void updateCharacterStream(String columnLabel, Reader reader) throws SQLException {
updateCharacterStream(findColumn(columnLabel), reader);
}
public void updateCharacterStream(String columnLabel, Reader reader, long length) throws SQLException {
updateCharacterStream(findColumn(columnLabel), reader, length);
}
public void updateClob(String columnLabel, Reader reader) throws SQLException {
updateClob(findColumn(columnLabel), reader);
}
public void updateClob(String columnLabel, Reader reader, long length) throws SQLException {
updateClob(findColumn(columnLabel), reader, length);
}
public void updateNCharacterStream(String columnLabel, Reader reader) throws SQLException {
updateNCharacterStream(findColumn(columnLabel), reader);
}
public void updateNCharacterStream(String columnLabel, Reader reader, long length) throws SQLException {
updateNCharacterStream(findColumn(columnLabel), reader, length);
}
public void updateNClob(String columnLabel, Reader reader) throws SQLException {
updateNClob(findColumn(columnLabel), reader);
}
public void updateNClob(String columnLabel, Reader reader, long length) throws SQLException {
updateNClob(findColumn(columnLabel), reader, length);
}
public void updateSQLXML(String columnLabel, SQLXML xmlObject) throws SQLException {
updateSQLXML(findColumn(columnLabel), xmlObject);
}
/**
* JDBC 4.0 Update a column with a character stream 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
* @param length
* the length of the stream
*
* @exception SQLException
* if a database-access error occurs
*/
public synchronized void updateNCharacterStream(int columnIndex,
java.io.Reader x, int length) throws SQLException {
String fieldEncoding = this.fields[columnIndex - 1].getCharacterSet();
if (fieldEncoding == null || !fieldEncoding.equals("UTF-8")) {
throw new SQLException(
"Can not call updateNCharacterStream() when field's character set isn't UTF-8");
}
if (!this.onInsertRow) {
if (!this.doingUpdates) {
this.doingUpdates = true;
syncUpdate();
}
((com.mysql.jdbc.JDBC4PreparedStatement)this.updater).setNCharacterStream(columnIndex, x, length);
} else {
((com.mysql.jdbc.JDBC4PreparedStatement)this.inserter).setNCharacterStream(columnIndex, x, length);
if (x == null) {
this.thisRow.setColumnValue(columnIndex, null);
} else {
this.thisRow.setColumnValue(columnIndex, STREAM_DATA_MARKER);
}
}
}
/**
* JDBC 4.0 Update a column with a character stream 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 reader
* the new column value
* @param length
* of the stream
*
* @exception SQLException
* if a database-access error occurs
*/
public synchronized void updateNCharacterStream(String columnName,
java.io.Reader reader, int length) throws SQLException {
updateNCharacterStream(findColumn(columnName), reader, length);
}
/**
* @see ResultSet#updateNClob(int, NClob)
*/
public void updateNClob(int columnIndex, java.sql.NClob nClob)
throws SQLException {
String fieldEncoding = this.fields[columnIndex - 1].getCharacterSet();
if (fieldEncoding == null || !fieldEncoding.equals("UTF-8")) {
throw new SQLException("Can not call updateNClob() when field's character set isn't UTF-8");
}
if (nClob == null) {
updateNull(columnIndex);
} else {
updateNCharacterStream(columnIndex, nClob.getCharacterStream(),
(int) nClob.length());
}
}
/**
* @see ResultSet#updateClob(int, Clob)
*/
public void updateNClob(String columnName, java.sql.NClob nClob)
throws SQLException {
updateNClob(findColumn(columnName), nClob);
}
/**
* JDBC 4.0 Update a column with NATIONAL CHARACTER. 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 updateNString(int columnIndex, String x)
throws SQLException {
String fieldEncoding = this.fields[columnIndex - 1].getCharacterSet();
if (fieldEncoding == null || !fieldEncoding.equals("UTF-8")) {
throw new SQLException("Can not call updateNString() when field's character set isn't UTF-8");
}
if (!this.onInsertRow) {
if (!this.doingUpdates) {
this.doingUpdates = true;
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -