提交 fc552032 authored 作者: Thomas Mueller's avatar Thomas Mueller

SimpleResultSet: updating a result set is now supported.

上级 b00ebad0
...@@ -348,230 +348,240 @@ public class SimpleResultSet implements ResultSet, ResultSetMetaData { ...@@ -348,230 +348,240 @@ public class SimpleResultSet implements ResultSet, ResultSetMetaData {
} }
/** /**
* Returns the value as a byte. * Searches for a specific column in the result set. A case-insensitive
* search is made.
* *
* @param columnIndex (1,2,...) * @param columnLabel the column label
* @return the value * @return the column index (1,2,...)
* @throws SQLException if the column is not found or if the result set is
* closed
*/ */
public byte getByte(int columnIndex) throws SQLException { public int findColumn(String columnLabel) throws SQLException {
Object o = get(columnIndex); if (columnLabel != null && columns != null) {
if (o != null && !(o instanceof Number)) { for (int i = 0, size = columns.size(); i < size; i++) {
o = Byte.decode(o.toString()); if (columnLabel.equalsIgnoreCase(getColumn(i).name)) {
return i + 1;
}
} }
return o == null ? 0 : ((Number) o).byteValue(); }
throw DbException.get(ErrorCode.COLUMN_NOT_FOUND_1, columnLabel).getSQLException();
} }
/** /**
* Returns the value as an double. * Returns a reference to itself.
* *
* @param columnIndex (1,2,...) * @return this
* @return the value
*/ */
public double getDouble(int columnIndex) throws SQLException { public ResultSetMetaData getMetaData() {
Object o = get(columnIndex); return this;
if (o != null && !(o instanceof Number)) {
return Double.parseDouble(o.toString());
}
return o == null ? 0 : ((Number) o).doubleValue();
} }
/** /**
* Returns the value as a float. * Returns null.
* *
* @param columnIndex (1,2,...) * @return null
* @return the value
*/ */
public float getFloat(int columnIndex) throws SQLException { public SQLWarning getWarnings() {
Object o = get(columnIndex); return null;
if (o != null && !(o instanceof Number)) {
return Float.parseFloat(o.toString());
}
return o == null ? 0 : ((Number) o).floatValue();
} }
/** /**
* Returns the value as an int. * Returns null.
* *
* @param columnIndex (1,2,...) * @return null
* @return the value
*/ */
public int getInt(int columnIndex) throws SQLException { public Statement getStatement() {
Object o = get(columnIndex); return null;
if (o != null && !(o instanceof Number)) {
o = Integer.decode(o.toString());
} }
return o == null ? 0 : ((Number) o).intValue();
/**
* INTERNAL
*/
public void clearWarnings() {
// nothing to do
} }
// ---- get ---------------------------------------------
/** /**
* Returns the value as a long. * Returns the value as a java.sql.Array.
* *
* @param columnIndex (1,2,...) * @param columnIndex (1,2,...)
* @return the value * @return the value
*/ */
public long getLong(int columnIndex) throws SQLException { public Array getArray(int columnIndex) throws SQLException {
Object o = get(columnIndex); Object[] o = (Object[]) get(columnIndex);
if (o != null && !(o instanceof Number)) { return o == null ? null : new SimpleArray(o);
o = Long.decode(o.toString());
}
return o == null ? 0 : ((Number) o).longValue();
} }
/** /**
* Returns the value as a short. * Returns the value as a java.sql.Array.
* *
* @param columnIndex (1,2,...) * @param columnLabel the column label
* @return the value * @return the value
*/ */
public short getShort(int columnIndex) throws SQLException { public Array getArray(String columnLabel) throws SQLException {
Object o = get(columnIndex); return getArray(findColumn(columnLabel));
if (o != null && !(o instanceof Number)) {
o = Short.decode(o.toString());
} }
return o == null ? 0 : ((Number) o).shortValue();
/**
* INTERNAL
*/
public InputStream getAsciiStream(int columnIndex) throws SQLException {
throw getUnsupportedException();
} }
/** /**
* Returns the value as a boolean. * INTERNAL
*/
public InputStream getAsciiStream(String columnLabel) throws SQLException {
throw getUnsupportedException();
}
/**
* Returns the value as a java.math.BigDecimal.
* *
* @param columnIndex (1,2,...) * @param columnIndex (1,2,...)
* @return the value * @return the value
*/ */
public boolean getBoolean(int columnIndex) throws SQLException { public BigDecimal getBigDecimal(int columnIndex) throws SQLException {
Object o = get(columnIndex); Object o = get(columnIndex);
if (o != null && !(o instanceof Boolean)) { if (o != null && !(o instanceof BigDecimal)) {
o = Boolean.valueOf(o.toString()); o = new BigDecimal(o.toString());
} }
return o == null ? false : ((Boolean) o).booleanValue(); return (BigDecimal) o;
} }
/** /**
* Returns the value as a byte array. * Returns the value as a java.math.BigDecimal.
* *
* @param columnIndex (1,2,...) * @param columnLabel the column label
* @return the value * @return the value
*/ */
public byte[] getBytes(int columnIndex) throws SQLException { public BigDecimal getBigDecimal(String columnLabel) throws SQLException {
return (byte[]) get(columnIndex); return getBigDecimal(findColumn(columnLabel));
} }
/** /**
* Returns the value as an Object. * @deprecated INTERNAL
*
* @param columnIndex (1,2,...)
* @return the value
*/ */
public Object getObject(int columnIndex) throws SQLException { public BigDecimal getBigDecimal(int columnIndex, int scale) throws SQLException {
return get(columnIndex); throw getUnsupportedException();
} }
/** /**
* Returns the value as a String. * @deprecated INTERNAL
*/
public BigDecimal getBigDecimal(String columnLabel, int scale) throws SQLException {
throw getUnsupportedException();
}
/**
* Returns the value as a java.io.InputStream.
* This is only supported if the
* result set was created using a Blob object.
* *
* @param columnIndex (1,2,...) * @param columnIndex (1,2,...)
* @return the value * @return the value
*/ */
public String getString(int columnIndex) throws SQLException { public InputStream getBinaryStream(int columnIndex) throws SQLException {
Object o = get(columnIndex); Blob b = (Blob) get(columnIndex);
if (o == null) { return b == null ? null : b.getBinaryStream();
return null;
}
switch (columns.get(columnIndex - 1).sqlType) {
case Types.CLOB:
Clob c = (Clob) o;
return c.getSubString(1, MathUtils.convertLongToInt(c.length()));
}
return o.toString();
} }
/** /**
* Returns the value as a byte. * Returns the value as a java.io.InputStream.
* This is only supported if the
* result set was created using a Blob object.
* *
* @param columnLabel the column label * @param columnLabel the column label
* @return the value * @return the value
*/ */
public byte getByte(String columnLabel) throws SQLException { public InputStream getBinaryStream(String columnLabel) throws SQLException {
return getByte(findColumn(columnLabel)); return getBinaryStream(findColumn(columnLabel));
} }
/** /**
* Returns the value as a double. * Returns the value as a java.sql.Blob.
* This is only supported if the
* result set was created using a Blob object.
* *
* @param columnLabel the column label * @param columnIndex (1,2,...)
* @return the value * @return the value
*/ */
public double getDouble(String columnLabel) throws SQLException { public Blob getBlob(int columnIndex) throws SQLException {
return getDouble(findColumn(columnLabel)); Blob b = (Blob) get(columnIndex);
return b == null ? null : b;
} }
/** /**
* Returns the value as a float. * Returns the value as a java.sql.Blob.
* This is only supported if the
* result set was created using a Blob object.
* *
* @param columnLabel the column label * @param columnLabel the column label
* @return the value * @return the value
*/ */
public float getFloat(String columnLabel) throws SQLException { public Blob getBlob(String columnLabel) throws SQLException {
return getFloat(findColumn(columnLabel)); return getBlob(findColumn(columnLabel));
} }
/** /**
* Searches for a specific column in the result set. A case-insensitive * Returns the value as a boolean.
* search is made.
* *
* @param columnLabel the column label * @param columnIndex (1,2,...)
* @return the column index (1,2,...) * @return the value
* @throws SQLException if the column is not found or if the result set is
* closed
*/ */
public int findColumn(String columnLabel) throws SQLException { public boolean getBoolean(int columnIndex) throws SQLException {
if (columnLabel != null && columns != null) { Object o = get(columnIndex);
for (int i = 0, size = columns.size(); i < size; i++) { if (o != null && !(o instanceof Boolean)) {
if (columnLabel.equalsIgnoreCase(getColumn(i).name)) { o = Boolean.valueOf(o.toString());
return i + 1;
}
}
} }
throw DbException.get(ErrorCode.COLUMN_NOT_FOUND_1, columnLabel).getSQLException(); return o == null ? false : ((Boolean) o).booleanValue();
} }
/** /**
* Returns the value as an int. * Returns the value as a boolean.
* *
* @param columnLabel the column label * @param columnLabel the column label
* @return the value * @return the value
*/ */
public int getInt(String columnLabel) throws SQLException { public boolean getBoolean(String columnLabel) throws SQLException {
return getInt(findColumn(columnLabel)); return getBoolean(findColumn(columnLabel));
} }
/** /**
* Returns the value as a long. * Returns the value as a byte.
* *
* @param columnLabel the column label * @param columnIndex (1,2,...)
* @return the value * @return the value
*/ */
public long getLong(String columnLabel) throws SQLException { public byte getByte(int columnIndex) throws SQLException {
return getLong(findColumn(columnLabel)); Object o = get(columnIndex);
if (o != null && !(o instanceof Number)) {
o = Byte.decode(o.toString());
}
return o == null ? 0 : ((Number) o).byteValue();
} }
/** /**
* Returns the value as a short. * Returns the value as a byte.
* *
* @param columnLabel the column label * @param columnLabel the column label
* @return the value * @return the value
*/ */
public short getShort(String columnLabel) throws SQLException { public byte getByte(String columnLabel) throws SQLException {
return getShort(findColumn(columnLabel)); return getByte(findColumn(columnLabel));
} }
/** /**
* Returns the value as a boolean. * Returns the value as a byte array.
* *
* @param columnLabel the column label * @param columnIndex (1,2,...)
* @return the value * @return the value
*/ */
public boolean getBoolean(String columnLabel) throws SQLException { public byte[] getBytes(int columnIndex) throws SQLException {
return getBoolean(findColumn(columnLabel)); return (byte[]) get(columnIndex);
} }
/** /**
...@@ -585,494 +595,616 @@ public class SimpleResultSet implements ResultSet, ResultSetMetaData { ...@@ -585,494 +595,616 @@ public class SimpleResultSet implements ResultSet, ResultSetMetaData {
} }
/** /**
* Returns the value as a java.math.BigDecimal. * Returns the value as a java.io.Reader.
* This is only supported for CLOB data.
* *
* @param columnIndex (1,2,...) * @param columnIndex (1,2,...)
* @return the value * @return the value
*/ */
public BigDecimal getBigDecimal(int columnIndex) throws SQLException { public Reader getCharacterStream(int columnIndex) throws SQLException {
Object o = get(columnIndex); Clob c = (Clob) get(columnIndex);
if (o != null && !(o instanceof BigDecimal)) { return c == null ? null : c.getCharacterStream();
o = new BigDecimal(o.toString());
}
return (BigDecimal) o;
} }
/** /**
* Returns the value as an java.sql.Date. * Returns the value as a java.io.Reader.
* This is only supported if the
* result set was created using a Clob object.
* *
* @param columnIndex (1,2,...) * @param columnLabel the column label
* @return the value * @return the value
*/ */
public Date getDate(int columnIndex) throws SQLException { public Reader getCharacterStream(String columnLabel) throws SQLException {
return (Date) get(columnIndex); return getCharacterStream(findColumn(columnLabel));
} }
/** /**
* Returns a reference to itself. * Returns the value as a java.sql.Clob.
* * This is only supported if the
* @return this * result set was created using a Clob object.
*/
public ResultSetMetaData getMetaData() {
return this;
}
/**
* Returns null.
* *
* @return null * @param columnIndex (1,2,...)
* @return the value
*/ */
public SQLWarning getWarnings() { public Clob getClob(int columnIndex) throws SQLException {
return null; Clob c = (Clob) get(columnIndex);
return c == null ? null : c;
} }
/** /**
* Returns null. * Returns the value as a java.sql.Clob.
* This is only supported if the
* result set was created using a Clob object.
* *
* @return null * @param columnLabel the column label
* @return the value
*/ */
public Statement getStatement() { public Clob getClob(String columnLabel) throws SQLException {
return null; return getClob(findColumn(columnLabel));
} }
/** /**
* Returns the value as an java.sql.Time. * Returns the value as an java.sql.Date.
* *
* @param columnIndex (1,2,...) * @param columnIndex (1,2,...)
* @return the value * @return the value
*/ */
public Time getTime(int columnIndex) throws SQLException { public Date getDate(int columnIndex) throws SQLException {
return (Time) get(columnIndex); return (Date) get(columnIndex);
} }
/** /**
* Returns the value as an java.sql.Timestamp. * Returns the value as a java.sql.Date.
* *
* @param columnIndex (1,2,...) * @param columnLabel the column label
* @return the value * @return the value
*/ */
public Timestamp getTimestamp(int columnIndex) throws SQLException { public Date getDate(String columnLabel) throws SQLException {
return (Timestamp) get(columnIndex); return getDate(findColumn(columnLabel));
} }
/** /**
* Returns the value as a java.sql.Array. * INTERNAL
*
* @param columnIndex (1,2,...)
* @return the value
*/ */
public Array getArray(int columnIndex) throws SQLException { public Date getDate(int columnIndex, Calendar cal) throws SQLException {
Object[] o = (Object[]) get(columnIndex); throw getUnsupportedException();
return o == null ? null : new SimpleArray(o);
} }
/** /**
* Returns the value as a java.io.Reader. * INTERNAL
* This is only supported for CLOB data.
*
* @param columnIndex (1,2,...)
* @return the value
*/ */
public Reader getCharacterStream(int columnIndex) throws SQLException { public Date getDate(String columnLabel, Calendar cal) throws SQLException {
Clob c = (Clob) get(columnIndex); throw getUnsupportedException();
return c == null ? null : c.getCharacterStream();
} }
/** /**
* Returns the value as a java.sql.Clob. * Returns the value as an double.
* This is only supported if the
* result set was created using a Clob object.
* *
* @param columnIndex (1,2,...) * @param columnIndex (1,2,...)
* @return the value * @return the value
*/ */
public Clob getClob(int columnIndex) throws SQLException { public double getDouble(int columnIndex) throws SQLException {
Clob c = (Clob) get(columnIndex); Object o = get(columnIndex);
return c == null ? null : c; if (o != null && !(o instanceof Number)) {
return Double.parseDouble(o.toString());
}
return o == null ? 0 : ((Number) o).doubleValue();
} }
/** /**
* Returns the value as a java.sql.Blob. * Returns the value as a double.
* This is only supported if the
* result set was created using a Blob object.
* *
* @param columnIndex (1,2,...) * @param columnLabel the column label
* @return the value * @return the value
*/ */
public Blob getBlob(int columnIndex) throws SQLException { public double getDouble(String columnLabel) throws SQLException {
Blob b = (Blob) get(columnIndex); return getDouble(findColumn(columnLabel));
return b == null ? null : b;
} }
/** /**
* Returns the value as a java.io.InputStream. * Returns the value as a float.
* This is only supported if the
* result set was created using a Blob object.
* *
* @param columnIndex (1,2,...) * @param columnIndex (1,2,...)
* @return the value * @return the value
*/ */
public InputStream getBinaryStream(int columnIndex) throws SQLException { public float getFloat(int columnIndex) throws SQLException {
Blob b = (Blob) get(columnIndex); Object o = get(columnIndex);
return b == null ? null : b.getBinaryStream(); if (o != null && !(o instanceof Number)) {
return Float.parseFloat(o.toString());
}
return o == null ? 0 : ((Number) o).floatValue();
} }
/** /**
* Returns the value as an Object. * Returns the value as a float.
* *
* @param columnLabel the column label * @param columnLabel the column label
* @return the value * @return the value
*/ */
public Object getObject(String columnLabel) throws SQLException { public float getFloat(String columnLabel) throws SQLException {
return getObject(findColumn(columnLabel)); return getFloat(findColumn(columnLabel));
} }
/** /**
* Returns the value as a String. * Returns the value as an int.
* *
* @param columnLabel the column label * @param columnIndex (1,2,...)
* @return the value * @return the value
*/ */
public String getString(String columnLabel) throws SQLException { public int getInt(int columnIndex) throws SQLException {
return getString(findColumn(columnLabel)); Object o = get(columnIndex);
if (o != null && !(o instanceof Number)) {
o = Integer.decode(o.toString());
}
return o == null ? 0 : ((Number) o).intValue();
} }
/** /**
* Returns the value as a java.math.BigDecimal. * Returns the value as an int.
* *
* @param columnLabel the column label * @param columnLabel the column label
* @return the value * @return the value
*/ */
public BigDecimal getBigDecimal(String columnLabel) throws SQLException { public int getInt(String columnLabel) throws SQLException {
return getBigDecimal(findColumn(columnLabel)); return getInt(findColumn(columnLabel));
} }
/** /**
* Returns the value as a java.sql.Date. * Returns the value as a long.
* *
* @param columnLabel the column label * @param columnIndex (1,2,...)
* @return the value * @return the value
*/ */
public Date getDate(String columnLabel) throws SQLException { public long getLong(int columnIndex) throws SQLException {
return getDate(findColumn(columnLabel)); Object o = get(columnIndex);
if (o != null && !(o instanceof Number)) {
o = Long.decode(o.toString());
}
return o == null ? 0 : ((Number) o).longValue();
} }
/** /**
* Returns the value as a java.sql.Time. * Returns the value as a long.
* *
* @param columnLabel the column label * @param columnLabel the column label
* @return the value * @return the value
*/ */
public Time getTime(String columnLabel) throws SQLException { public long getLong(String columnLabel) throws SQLException {
return getTime(findColumn(columnLabel)); return getLong(findColumn(columnLabel));
} }
/** /**
* Returns the value as a java.sql.Timestamp. * INTERNAL
*
* @param columnLabel the column label
* @return the value
*/ */
public Timestamp getTimestamp(String columnLabel) throws SQLException { //## Java 1.6 ##
return getTimestamp(findColumn(columnLabel)); public Reader getNCharacterStream(int columnIndex) throws SQLException {
throw getUnsupportedException();
} }
//*/
/** /**
* Returns the value as a java.io.Reader. * INTERNAL
* This is only supported if the
* result set was created using a Clob object.
*
* @param columnLabel the column label
* @return the value
*/ */
public Reader getCharacterStream(String columnLabel) throws SQLException { //## Java 1.6 ##
return getCharacterStream(findColumn(columnLabel)); public Reader getNCharacterStream(String columnLabel) throws SQLException {
throw getUnsupportedException();
} }
//*/
/** /**
* Returns the value as a java.sql.Clob. * INTERNAL
* This is only supported if the
* result set was created using a Clob object.
*
* @param columnLabel the column label
* @return the value
*/ */
public Clob getClob(String columnLabel) throws SQLException { //## Java 1.6 ##
return getClob(findColumn(columnLabel)); public NClob getNClob(int columnIndex) throws SQLException {
throw getUnsupportedException();
} }
//*/
/** /**
* Returns the value as a java.sql.Blob. * INTERNAL
* This is only supported if the
* result set was created using a Blob object.
*
* @param columnLabel the column label
* @return the value
*/ */
public Blob getBlob(String columnLabel) throws SQLException { //## Java 1.6 ##
return getBlob(findColumn(columnLabel)); public NClob getNClob(String columnLabel) throws SQLException {
throw getUnsupportedException();
} }
//*/
/** /**
* Returns the value as a java.io.InputStream. * INTERNAL
* This is only supported if the
* result set was created using a Blob object.
*
* @param columnLabel the column label
* @return the value
*/ */
public InputStream getBinaryStream(String columnLabel) throws SQLException { //## Java 1.6 ##
return getBinaryStream(findColumn(columnLabel)); public String getNString(int columnIndex) throws SQLException {
return getString(columnIndex);
} }
//*/
// ---- result set meta data ---------------------------------------------
/** /**
* Returns the column count. * INTERNAL
*
* @return the column count
*/ */
public int getColumnCount() { //## Java 1.6 ##
return columns.size(); public String getNString(String columnLabel) throws SQLException {
return getString(columnLabel);
} }
//*/
/** /**
* Returns 15. * Returns the value as an Object.
* *
* @param columnIndex (1,2,...) * @param columnIndex (1,2,...)
* @return 15 * @return the value
*/ */
public int getColumnDisplaySize(int columnIndex) { public Object getObject(int columnIndex) throws SQLException {
return 15; return get(columnIndex);
} }
/** /**
* Returns the SQL type. * Returns the value as an Object.
* *
* @param columnIndex (1,2,...) * @param columnLabel the column label
* @return the SQL type * @return the value
*/ */
public int getColumnType(int columnIndex) throws SQLException { public Object getObject(String columnLabel) throws SQLException {
return getColumn(columnIndex - 1).sqlType; return getObject(findColumn(columnLabel));
} }
/** /**
* Returns the precision. * INTERNAL
* *
* @param columnIndex (1,2,...) * @param columnIndex the column index (1, 2, ...)
* @return the precision * @param type the class of the returned value
*/ */
public int getPrecision(int columnIndex) throws SQLException { /*## Java 1.7 ##
return getColumn(columnIndex - 1).precision; public <T> T getObject(int columnIndex, Class<T> type) {
return null;
} }
//*/
/** /**
* Returns the scale. * INTERNAL
* *
* @param columnIndex (1,2,...) * @param columnName the column name
* @return the scale * @param type the class of the returned value
*/ */
public int getScale(int columnIndex) throws SQLException { /*## Java 1.7 ##
return getColumn(columnIndex - 1).scale; public <T> T getObject(String columnName, Class<T> type) {
return null;
} }
//*/
/** /**
* Returns ResultSetMetaData.columnNullableUnknown. * INTERNAL
*
* @param columnIndex (1,2,...)
* @return columnNullableUnknown
*/ */
public int isNullable(int columnIndex) { public Object getObject(int columnIndex, Map<String, Class<?>> map) throws SQLException {
return ResultSetMetaData.columnNullableUnknown; throw getUnsupportedException();
} }
/** /**
* Returns false. * INTERNAL
*
* @param columnIndex (1,2,...)
* @return false
*/ */
public boolean isAutoIncrement(int columnIndex) { public Object getObject(String columnLabel, Map<String, Class<?>> map) throws SQLException {
return false; throw getUnsupportedException();
} }
/** /**
* Returns true. * INTERNAL
*
* @param columnIndex (1,2,...)
* @return true
*/ */
public boolean isCaseSensitive(int columnIndex) { public Ref getRef(int columnIndex) throws SQLException {
return true; throw getUnsupportedException();
} }
/** /**
* Returns false. * INTERNAL
*
* @param columnIndex (1,2,...)
* @return false
*/ */
public boolean isCurrency(int columnIndex) { public Ref getRef(String columnLabel) throws SQLException {
return false; throw getUnsupportedException();
} }
/** /**
* Returns false. * INTERNAL
*
* @param columnIndex (1,2,...)
* @return false
*/ */
public boolean isDefinitelyWritable(int columnIndex) { //## Java 1.6 ##
return false; public RowId getRowId(int columnIndex) throws SQLException {
throw getUnsupportedException();
} }
//*/
/** /**
* Returns true. * INTERNAL
*/
//## Java 1.6 ##
public RowId getRowId(String columnLabel) throws SQLException {
throw getUnsupportedException();
}
//*/
/**
* Returns the value as a short.
* *
* @param columnIndex (1,2,...) * @param columnIndex (1,2,...)
* @return true * @return the value
*/ */
public boolean isReadOnly(int columnIndex) { public short getShort(int columnIndex) throws SQLException {
return true; Object o = get(columnIndex);
if (o != null && !(o instanceof Number)) {
o = Short.decode(o.toString());
}
return o == null ? 0 : ((Number) o).shortValue();
} }
/** /**
* Returns true. * Returns the value as a short.
* *
* @param columnIndex (1,2,...) * @param columnLabel the column label
* @return true * @return the value
*/ */
public boolean isSearchable(int columnIndex) { public short getShort(String columnLabel) throws SQLException {
return true; return getShort(findColumn(columnLabel));
} }
/** /**
* Returns true. * INTERNAL
*/
//## Java 1.6 ##
public SQLXML getSQLXML(int columnIndex) throws SQLException {
throw getUnsupportedException();
}
//*/
/**
* INTERNAL
*/
//## Java 1.6 ##
public SQLXML getSQLXML(String columnLabel) throws SQLException {
throw getUnsupportedException();
}
//*/
/**
* Returns the value as a String.
* *
* @param columnIndex (1,2,...) * @param columnIndex (1,2,...)
* @return true * @return the value
*/ */
public boolean isSigned(int columnIndex) { public String getString(int columnIndex) throws SQLException {
return true; Object o = get(columnIndex);
if (o == null) {
return null;
}
switch (columns.get(columnIndex - 1).sqlType) {
case Types.CLOB:
Clob c = (Clob) o;
return c.getSubString(1, MathUtils.convertLongToInt(c.length()));
}
return o.toString();
} }
/** /**
* Returns false. * Returns the value as a String.
* *
* @param columnIndex (1,2,...) * @param columnLabel the column label
* @return false * @return the value
*/ */
public boolean isWritable(int columnIndex) { public String getString(String columnLabel) throws SQLException {
return false; return getString(findColumn(columnLabel));
} }
/** /**
* Returns null. * Returns the value as an java.sql.Time.
* *
* @param columnIndex (1,2,...) * @param columnIndex (1,2,...)
* @return null * @return the value
*/ */
public String getCatalogName(int columnIndex) { public Time getTime(int columnIndex) throws SQLException {
return null; return (Time) get(columnIndex);
} }
/** /**
* Returns the Java class name if this column. * Returns the value as a java.sql.Time.
* *
* @param columnIndex (1,2,...) * @param columnLabel the column label
* @return the class name * @return the value
*/ */
public String getColumnClassName(int columnIndex) throws SQLException { public Time getTime(String columnLabel) throws SQLException {
int sqlType = getColumn(columnIndex - 1).sqlType; return getTime(findColumn(columnLabel));
int type = DataType.convertSQLTypeToValueType(sqlType);
return DataType.getTypeClassName(type);
} }
/** /**
* Returns the column label. * INTERNAL
*/
public Time getTime(int columnIndex, Calendar cal) throws SQLException {
throw getUnsupportedException();
}
/**
* INTERNAL
*/
public Time getTime(String columnLabel, Calendar cal) throws SQLException {
throw getUnsupportedException();
}
/**
* Returns the value as an java.sql.Timestamp.
* *
* @param columnIndex (1,2,...) * @param columnIndex (1,2,...)
* @return the column label * @return the value
*/ */
public String getColumnLabel(int columnIndex) throws SQLException { public Timestamp getTimestamp(int columnIndex) throws SQLException {
return getColumn(columnIndex - 1).name; return (Timestamp) get(columnIndex);
} }
/** /**
* Returns the column name. * Returns the value as a java.sql.Timestamp.
* *
* @param columnIndex (1,2,...) * @param columnLabel the column label
* @return the column name * @return the value
*/ */
public String getColumnName(int columnIndex) throws SQLException { public Timestamp getTimestamp(String columnLabel) throws SQLException {
return getColumnLabel(columnIndex); return getTimestamp(findColumn(columnLabel));
}
/**
* INTERNAL
*/
public Timestamp getTimestamp(int columnIndex, Calendar cal) throws SQLException {
throw getUnsupportedException();
}
/**
* INTERNAL
*/
public Timestamp getTimestamp(String columnLabel, Calendar cal) throws SQLException {
throw getUnsupportedException();
}
/**
* @deprecated INTERNAL
*/
public InputStream getUnicodeStream(int columnIndex) throws SQLException {
throw getUnsupportedException();
}
/**
* @deprecated INTERNAL
*/
public InputStream getUnicodeStream(String columnLabel) throws SQLException {
throw getUnsupportedException();
}
/**
* INTERNAL
*/
public URL getURL(int columnIndex) throws SQLException {
throw getUnsupportedException();
}
/**
* INTERNAL
*/
public URL getURL(String columnLabel) throws SQLException {
throw getUnsupportedException();
}
// ---- update ---------------------------------------------
/**
* INTERNAL
*/
public void updateArray(int columnIndex, Array x) throws SQLException {
update(columnIndex, x);
}
/**
* INTERNAL
*/
public void updateArray(String columnLabel, Array x) throws SQLException {
update(columnLabel, x);
}
/**
* INTERNAL
*/
//## Java 1.6 ##
public void updateAsciiStream(int columnIndex, InputStream x) throws SQLException {
update(columnIndex, x);
}
//*/
/**
* INTERNAL
*/
//## Java 1.6 ##
public void updateAsciiStream(String columnLabel, InputStream x) throws SQLException {
update(columnLabel, x);
}
//*/
/**
* INTERNAL
*/
public void updateAsciiStream(int columnIndex, InputStream x, int length) throws SQLException {
update(columnIndex, x);
}
/**
* INTERNAL
*/
public void updateAsciiStream(String columnLabel, InputStream x, int length) throws SQLException {
update(columnLabel, x);
}
/**
* INTERNAL
*/
//## Java 1.6 ##
public void updateAsciiStream(int columnIndex, InputStream x, long length)
throws SQLException {
update(columnIndex, x);
}
//*/
/**
* INTERNAL
*/
//## Java 1.6 ##
public void updateAsciiStream(String columnLabel, InputStream x, long length)
throws SQLException {
update(columnLabel, x);
} }
//*/
/** /**
* Returns the data type name of a column. * INTERNAL
*
* @param columnIndex (1,2,...)
* @return the type name
*/ */
public String getColumnTypeName(int columnIndex) throws SQLException { public void updateBigDecimal(int columnIndex, BigDecimal x) throws SQLException {
int sqlType = getColumn(columnIndex - 1).sqlType; update(columnIndex, x);
int type = DataType.convertSQLTypeToValueType(sqlType);
return DataType.getDataType(type).name;
} }
/** /**
* Returns null. * INTERNAL
*
* @param columnIndex (1,2,...)
* @return null
*/ */
public String getSchemaName(int columnIndex) { public void updateBigDecimal(String columnLabel, BigDecimal x) throws SQLException {
return null; update(columnLabel, x);
} }
/** /**
* Returns null. * INTERNAL
*
* @param columnIndex (1,2,...)
* @return null
*/ */
public String getTableName(int columnIndex) { //## Java 1.6 ##
return null; public void updateBinaryStream(int columnIndex, InputStream x) throws SQLException {
update(columnIndex, x);
} }
//*/
/** /**
* INTERNAL * INTERNAL
*/ */
public void clearWarnings() { //## Java 1.6 ##
// nothing to do public void updateBinaryStream(String columnLabel, InputStream x) throws SQLException {
update(columnLabel, x);
} }
//*/
// ---- unsupported / result set ---------------------------------------------
/** /**
* INTERNAL * INTERNAL
*/ */
public void updateArray(int columnIndex, Array x) throws SQLException { public void updateBinaryStream(int columnIndex, InputStream x, int length) throws SQLException {
throw getUnsupportedException(); update(columnIndex, x);
} }
/** /**
* Returns the value as a java.sql.Array. * INTERNAL
*
* @param columnLabel the column label
* @return the value
*/ */
public Array getArray(String columnLabel) throws SQLException { public void updateBinaryStream(String columnLabel, InputStream x, int length) throws SQLException {
return getArray(findColumn(columnLabel)); update(columnLabel, x);
} }
/** /**
* INTERNAL * INTERNAL
*/ */
//## Java 1.6 ## //## Java 1.6 ##
public void updateAsciiStream(int columnIndex, InputStream x) public void updateBinaryStream(int columnIndex, InputStream x, long length)
throws SQLException { throws SQLException {
throw getUnsupportedException(); update(columnIndex, x);
} }
//*/ //*/
...@@ -1080,33 +1212,51 @@ public class SimpleResultSet implements ResultSet, ResultSetMetaData { ...@@ -1080,33 +1212,51 @@ public class SimpleResultSet implements ResultSet, ResultSetMetaData {
* INTERNAL * INTERNAL
*/ */
//## Java 1.6 ## //## Java 1.6 ##
public void updateAsciiStream(String columnLabel, InputStream x) public void updateBinaryStream(String columnLabel, InputStream x, long length)
throws SQLException { throws SQLException {
throw getUnsupportedException(); update(columnLabel, x);
} }
//*/ //*/
/** /**
* INTERNAL * INTERNAL
*/ */
public void updateAsciiStream(int columnIndex, InputStream x, int length) throws SQLException { public void updateBlob(int columnIndex, Blob x) throws SQLException {
throw getUnsupportedException(); update(columnIndex, x);
} }
/** /**
* INTERNAL * INTERNAL
*/ */
public void updateAsciiStream(String columnLabel, InputStream x, int length) throws SQLException { public void updateBlob(String columnLabel, Blob x) throws SQLException {
throw getUnsupportedException(); update(columnLabel, x);
} }
/** /**
* INTERNAL * INTERNAL
*/ */
//## Java 1.6 ## //## Java 1.6 ##
public void updateAsciiStream(int columnIndex, InputStream x, long length) public void updateBlob(int columnIndex, InputStream x) throws SQLException {
update(columnIndex, x);
}
//*/
/**
* INTERNAL
*/
//## Java 1.6 ##
public void updateBlob(String columnLabel, InputStream x) throws SQLException {
update(columnLabel, x);
}
//*/
/**
* INTERNAL
*/
//## Java 1.6 ##
public void updateBlob(int columnIndex, InputStream x, long length)
throws SQLException { throws SQLException {
throw getUnsupportedException(); update(columnIndex, x);
} }
//*/ //*/
...@@ -1114,67 +1264,60 @@ public class SimpleResultSet implements ResultSet, ResultSetMetaData { ...@@ -1114,67 +1264,60 @@ public class SimpleResultSet implements ResultSet, ResultSetMetaData {
* INTERNAL * INTERNAL
*/ */
//## Java 1.6 ## //## Java 1.6 ##
public void updateAsciiStream(String columnLabel, InputStream x, long length) public void updateBlob(String columnLabel, InputStream x, long length)
throws SQLException { throws SQLException {
throw getUnsupportedException(); update(columnLabel, x);
} }
//*/ //*/
/** /**
* INTERNAL * INTERNAL
*/ */
public void updateBigDecimal(int columnIndex, BigDecimal x) throws SQLException { public void updateBoolean(int columnIndex, boolean x) throws SQLException {
throw getUnsupportedException(); update(columnIndex, x);
} }
/** /**
* INTERNAL * INTERNAL
*/ */
public void updateBigDecimal(String columnLabel, BigDecimal x) throws SQLException { public void updateBoolean(String columnLabel, boolean x) throws SQLException {
throw getUnsupportedException(); update(columnLabel, x);
} }
/** /**
* INTERNAL * INTERNAL
*/ */
//## Java 1.6 ## public void updateByte(int columnIndex, byte x) throws SQLException {
public void updateBinaryStream(int columnLabel, InputStream x) update(columnIndex, x);
throws SQLException {
throw getUnsupportedException();
} }
//*/
/** /**
* INTERNAL * INTERNAL
*/ */
//## Java 1.6 ## public void updateByte(String columnLabel, byte x) throws SQLException {
public void updateBinaryStream(String columnLabel, InputStream x) update(columnLabel, x);
throws SQLException {
throw getUnsupportedException();
} }
//*/
/** /**
* INTERNAL * INTERNAL
*/ */
public void updateBinaryStream(int columnIndex, InputStream x, int length) throws SQLException { public void updateBytes(int columnIndex, byte[] x) throws SQLException {
throw getUnsupportedException(); update(columnIndex, x);
} }
/** /**
* INTERNAL * INTERNAL
*/ */
public void updateBinaryStream(String columnLabel, InputStream x, int length) throws SQLException { public void updateBytes(String columnLabel, byte[] x) throws SQLException {
throw getUnsupportedException(); update(columnLabel, x);
} }
/** /**
* INTERNAL * INTERNAL
*/ */
//## Java 1.6 ## //## Java 1.6 ##
public void updateBinaryStream(int columnIndex, InputStream x, long length) public void updateCharacterStream(int columnIndex, Reader x) throws SQLException {
throws SQLException { update(columnIndex, x);
throw getUnsupportedException();
} }
//*/ //*/
...@@ -1182,290 +1325,333 @@ public class SimpleResultSet implements ResultSet, ResultSetMetaData { ...@@ -1182,290 +1325,333 @@ public class SimpleResultSet implements ResultSet, ResultSetMetaData {
* INTERNAL * INTERNAL
*/ */
//## Java 1.6 ## //## Java 1.6 ##
public void updateBinaryStream(String columnLabel, InputStream x, long length) public void updateCharacterStream(String columnLabel, Reader x) throws SQLException {
throws SQLException { update(columnLabel, x);
throw getUnsupportedException();
} }
//*/ //*/
/** /**
* INTERNAL * INTERNAL
*/ */
public void updateBlob(int columnIndex, Blob x) throws SQLException { public void updateCharacterStream(int columnIndex, Reader x, int length) throws SQLException {
throw getUnsupportedException(); update(columnIndex, x);
} }
/** /**
* INTERNAL * INTERNAL
*/ */
public void updateBlob(String columnLabel, Blob x) throws SQLException { public void updateCharacterStream(String columnLabel, Reader x, int length) throws SQLException {
throw getUnsupportedException(); update(columnLabel, x);
} }
/** /**
* INTERNAL * INTERNAL
*/ */
public void updateBoolean(int columnIndex, boolean x) throws SQLException { //## Java 1.6 ##
throw getUnsupportedException(); public void updateCharacterStream(int columnIndex, Reader x, long length)
throws SQLException {
update(columnIndex, x);
} }
//*/
/** /**
* INTERNAL * INTERNAL
*/ */
public void updateBoolean(String columnLabel, boolean x) throws SQLException { //## Java 1.6 ##
throw getUnsupportedException(); public void updateCharacterStream(String columnLabel, Reader x, long length)
throws SQLException {
update(columnLabel, x);
} }
//*/
/** /**
* INTERNAL * INTERNAL
*/ */
public void updateNull(int columnIndex) throws SQLException { public void updateClob(int columnIndex, Clob x) throws SQLException {
throw getUnsupportedException(); update(columnIndex, x);
} }
/** /**
* INTERNAL * INTERNAL
*/ */
public void updateNull(String columnLabel) throws SQLException { public void updateClob(String columnLabel, Clob x) throws SQLException {
throw getUnsupportedException(); update(columnLabel, x);
} }
/** /**
* INTERNAL * INTERNAL
*/ */
public void updateByte(int columnIndex, byte x) throws SQLException { //## Java 1.6 ##
throw getUnsupportedException(); public void updateClob(int columnIndex, Reader x) throws SQLException {
update(columnIndex, x);
} }
//*/
/** /**
* INTERNAL * INTERNAL
*/ */
public void updateByte(String columnLabel, byte x) throws SQLException { //## Java 1.6 ##
throw getUnsupportedException(); public void updateClob(String columnLabel, Reader x) throws SQLException {
update(columnLabel, x);
} }
//*/
/** /**
* INTERNAL * INTERNAL
*/ */
public void updateShort(int columnIndex, short x) throws SQLException { //## Java 1.6 ##
throw getUnsupportedException(); public void updateClob(int columnIndex, Reader x, long length)
throws SQLException {
update(columnIndex, x);
} }
//*/
/** /**
* INTERNAL * INTERNAL
*/ */
public void updateShort(String columnLabel, short x) throws SQLException { //## Java 1.6 ##
throw getUnsupportedException(); public void updateClob(String columnLabel, Reader x, long length)
throws SQLException {
update(columnLabel, x);
} }
//*/
/** /**
* INTERNAL * INTERNAL
*/ */
public void updateInt(int columnIndex, int x) throws SQLException { public void updateDate(int columnIndex, Date x) throws SQLException {
throw getUnsupportedException(); update(columnIndex, x);
} }
/** /**
* INTERNAL * INTERNAL
*/ */
public void updateInt(String columnLabel, int x) throws SQLException { public void updateDate(String columnLabel, Date x) throws SQLException {
throw getUnsupportedException(); update(columnLabel, x);
} }
/** /**
* INTERNAL * INTERNAL
*/ */
public void updateLong(int columnIndex, long x) throws SQLException { public void updateDouble(int columnIndex, double x) throws SQLException {
throw getUnsupportedException(); update(columnIndex, x);
} }
/** /**
* INTERNAL * INTERNAL
*/ */
public void updateLong(String columnLabel, long x) throws SQLException { public void updateDouble(String columnLabel, double x) throws SQLException {
throw getUnsupportedException(); update(columnLabel, x);
} }
/** /**
* INTERNAL * INTERNAL
*/ */
public void updateFloat(int columnIndex, float x) throws SQLException { public void updateFloat(int columnIndex, float x) throws SQLException {
throw getUnsupportedException(); update(columnIndex, x);
} }
/** /**
* INTERNAL * INTERNAL
*/ */
public void updateFloat(String columnLabel, float x) throws SQLException { public void updateFloat(String columnLabel, float x) throws SQLException {
throw getUnsupportedException(); update(columnLabel, x);
} }
/** /**
* INTERNAL * INTERNAL
*/ */
public void updateDouble(int columnIndex, double x) throws SQLException { public void updateInt(int columnIndex, int x) throws SQLException {
throw getUnsupportedException(); update(columnIndex, x);
} }
/** /**
* INTERNAL * INTERNAL
*/ */
public void updateDouble(String columnLabel, double x) throws SQLException { public void updateInt(String columnLabel, int x) throws SQLException {
throw getUnsupportedException(); update(columnLabel, x);
} }
/** /**
* INTERNAL * INTERNAL
*/ */
public void updateString(int columnIndex, String x) throws SQLException { public void updateLong(int columnIndex, long x) throws SQLException {
throw getUnsupportedException(); update(columnIndex, x);
} }
/** /**
* INTERNAL * INTERNAL
*/ */
public void updateString(String columnLabel, String x) throws SQLException { public void updateLong(String columnLabel, long x) throws SQLException {
throw getUnsupportedException(); update(columnLabel, x);
} }
/** /**
* INTERNAL * INTERNAL
*/ */
public void updateDate(int columnIndex, Date x) throws SQLException { //## Java 1.6 ##
throw getUnsupportedException(); public void updateNCharacterStream(int columnIndex, Reader x) throws SQLException {
update(columnIndex, x);
} }
//*/
/** /**
* INTERNAL * INTERNAL
*/ */
public void updateDate(String columnLabel, Date x) throws SQLException { //## Java 1.6 ##
throw getUnsupportedException(); public void updateNCharacterStream(String columnLabel, Reader x) throws SQLException {
update(columnLabel, x);
} }
//*/
/** /**
* INTERNAL * INTERNAL
*/ */
public void updateTime(int columnIndex, Time x) throws SQLException { //## Java 1.6 ##
throw getUnsupportedException(); public void updateNCharacterStream(int columnIndex, Reader x, long length)
throws SQLException {
update(columnIndex, x);
} }
//*/
/** /**
* INTERNAL * INTERNAL
*/ */
public void updateTime(String columnLabel, Time x) throws SQLException { //## Java 1.6 ##
throw getUnsupportedException(); public void updateNCharacterStream(String columnLabel, Reader x, long length)
throws SQLException {
update(columnLabel, x);
} }
//*/
/** /**
* INTERNAL * INTERNAL
*/ */
public void updateTimestamp(int columnIndex, Timestamp x) throws SQLException { //## Java 1.6 ##
throw getUnsupportedException(); public void updateNClob(int columnIndex, NClob x) throws SQLException {
update(columnIndex, x);
} }
//*/
/** /**
* INTERNAL * INTERNAL
*/ */
public void updateTimestamp(String columnLabel, Timestamp x) throws SQLException { //## Java 1.6 ##
throw getUnsupportedException(); public void updateNClob(String columnLabel, NClob x) throws SQLException {
update(columnLabel, x);
} }
//*/
/** /**
* INTERNAL * INTERNAL
*/ */
public void updateObject(int columnIndex, Object x) throws SQLException { //## Java 1.6 ##
throw getUnsupportedException(); public void updateNClob(int columnIndex, Reader x) throws SQLException {
update(columnIndex, x);
} }
//*/
/** /**
* INTERNAL * INTERNAL
*/ */
public void updateObject(String columnLabel, Object x) throws SQLException { //## Java 1.6 ##
throw getUnsupportedException(); public void updateNClob(String columnLabel, Reader x) throws SQLException {
update(columnLabel, x);
} }
//*/
/** /**
* INTERNAL * INTERNAL
*/ */
public void updateObject(int columnIndex, Object x, int scale) throws SQLException { //## Java 1.6 ##
throw getUnsupportedException(); public void updateNClob(int columnIndex, Reader x, long length)
throws SQLException {
update(columnIndex, x);
} }
//*/
/** /**
* INTERNAL * INTERNAL
*/ */
public void updateObject(String columnLabel, Object x, int scale) throws SQLException { //## Java 1.6 ##
throw getUnsupportedException(); public void updateNClob(String columnLabel, Reader x, long length)
throws SQLException {
update(columnLabel, x);
} }
//*/
/** /**
* INTERNAL * INTERNAL
*/ */
public void updateBytes(int columnIndex, byte[] x) throws SQLException { //## Java 1.6 ##
throw getUnsupportedException(); public void updateNString(int columnIndex, String x) throws SQLException {
update(columnIndex, x);
} }
//*/
/** /**
* INTERNAL * INTERNAL
*/ */
public void updateBytes(String columnLabel, byte[] x) throws SQLException { //## Java 1.6 ##
throw getUnsupportedException(); public void updateNString(String columnLabel, String x) throws SQLException {
update(columnLabel, x);
} }
//*/
/** /**
* INTERNAL * INTERNAL
*/ */
public void updateCharacterStream(int columnIndex, Reader x, int length) throws SQLException { public void updateNull(int columnIndex) throws SQLException {
throw getUnsupportedException(); update(columnIndex, null);
} }
/** /**
* INTERNAL * INTERNAL
*/ */
public URL getURL(int columnIndex) throws SQLException { public void updateNull(String columnLabel) throws SQLException {
throw getUnsupportedException(); update(columnLabel, null);
} }
/** /**
* INTERNAL * INTERNAL
*/ */
public void updateClob(int columnIndex, Clob x) throws SQLException { public void updateObject(int columnIndex, Object x) throws SQLException {
throw getUnsupportedException(); update(columnIndex, x);
} }
/** /**
* INTERNAL * INTERNAL
*/ */
public void updateRef(int columnIndex, Ref x) throws SQLException { public void updateObject(String columnLabel, Object x) throws SQLException {
throw getUnsupportedException(); update(columnLabel, x);
} }
/** /**
* INTERNAL * INTERNAL
*/ */
public void updateRef(String columnLabel, Ref x) throws SQLException { public void updateObject(int columnIndex, Object x, int scale) throws SQLException {
throw getUnsupportedException(); update(columnIndex, x);
} }
/** /**
* INTERNAL * INTERNAL
*/ */
public void updateCharacterStream(String columnLabel, Reader reader, int length) throws SQLException { public void updateObject(String columnLabel, Object x, int scale) throws SQLException {
throw getUnsupportedException(); update(columnLabel, x);
} }
/** /**
* INTERNAL * INTERNAL
*/ */
public void updateArray(String columnLabel, Array x) throws SQLException { public void updateRef(int columnIndex, Ref x) throws SQLException {
throw getUnsupportedException(); update(columnIndex, x);
} }
/** /**
* INTERNAL * INTERNAL
*/ */
public void updateClob(String columnLabel, Clob x) throws SQLException { public void updateRef(String columnLabel, Ref x) throws SQLException {
throw getUnsupportedException(); update(columnLabel, x);
} }
/** /**
...@@ -1473,7 +1659,7 @@ public class SimpleResultSet implements ResultSet, ResultSetMetaData { ...@@ -1473,7 +1659,7 @@ public class SimpleResultSet implements ResultSet, ResultSetMetaData {
*/ */
//## Java 1.6 ## //## Java 1.6 ##
public void updateRowId(int columnIndex, RowId x) throws SQLException { public void updateRowId(int columnIndex, RowId x) throws SQLException {
throw getUnsupportedException(); update(columnIndex, x);
} }
//*/ //*/
...@@ -1482,37 +1668,30 @@ public class SimpleResultSet implements ResultSet, ResultSetMetaData { ...@@ -1482,37 +1668,30 @@ public class SimpleResultSet implements ResultSet, ResultSetMetaData {
*/ */
//## Java 1.6 ## //## Java 1.6 ##
public void updateRowId(String columnLabel, RowId x) throws SQLException { public void updateRowId(String columnLabel, RowId x) throws SQLException {
throw getUnsupportedException(); update(columnLabel, x);
} }
//*/ //*/
/** /**
* INTERNAL * INTERNAL
*/ */
//## Java 1.6 ## public void updateShort(int columnIndex, short x) throws SQLException {
public void updateNString(int columnIndex, String nString) update(columnIndex, x);
throws SQLException {
throw getUnsupportedException();
} }
//*/
/** /**
* INTERNAL * INTERNAL
*/ */
//## Java 1.6 ## public void updateShort(String columnLabel, short x) throws SQLException {
public void updateNString(String columnLabel, String nString) update(columnLabel, x);
throws SQLException {
throw getUnsupportedException();
} }
//*/
/** /**
* INTERNAL * INTERNAL
*/ */
//## Java 1.6 ## //## Java 1.6 ##
public void updateNClob(int columnIndex, NClob nClob) public void updateSQLXML(int columnIndex, SQLXML x) throws SQLException {
throws SQLException { update(columnIndex, x);
throw getUnsupportedException();
} }
//*/ //*/
...@@ -1520,233 +1699,270 @@ public class SimpleResultSet implements ResultSet, ResultSetMetaData { ...@@ -1520,233 +1699,270 @@ public class SimpleResultSet implements ResultSet, ResultSetMetaData {
* INTERNAL * INTERNAL
*/ */
//## Java 1.6 ## //## Java 1.6 ##
public void updateNClob(String columnLabel, NClob nClob) public void updateSQLXML(String columnLabel, SQLXML x) throws SQLException {
throws SQLException { update(columnLabel, x);
throw getUnsupportedException();
} }
//*/ //*/
/** /**
* INTERNAL * INTERNAL
*/ */
//## Java 1.6 ## public void updateString(int columnIndex, String x) throws SQLException {
public void updateSQLXML(int columnIndex, SQLXML xmlObject) update(columnIndex, x);
throws SQLException {
throw getUnsupportedException();
} }
//*/
/** /**
* INTERNAL * INTERNAL
*/ */
//## Java 1.6 ## public void updateString(String columnLabel, String x) throws SQLException {
public void updateSQLXML(String columnLabel, SQLXML xmlObject) update(columnLabel, x);
throws SQLException {
throw getUnsupportedException();
} }
//*/
/** /**
* INTERNAL * INTERNAL
*/ */
//## Java 1.6 ## public void updateTime(int columnIndex, Time x) throws SQLException {
public void updateBlob(int columnIndex, InputStream x) throws SQLException { update(columnIndex, x);
throw getUnsupportedException();
} }
//*/
/** /**
* INTERNAL * INTERNAL
*/ */
//## Java 1.6 ## public void updateTime(String columnLabel, Time x) throws SQLException {
public void updateBlob(String columnLabel, InputStream x) throws SQLException { update(columnLabel, x);
throw getUnsupportedException();
} }
//*/
/** /**
* INTERNAL * INTERNAL
*/ */
//## Java 1.6 ## public void updateTimestamp(int columnIndex, Timestamp x) throws SQLException {
public void updateBlob(int columnIndex, InputStream x, long length) update(columnIndex, x);
throws SQLException {
throw getUnsupportedException();
} }
//*/
/** /**
* INTERNAL * INTERNAL
*/ */
//## Java 1.6 ## public void updateTimestamp(String columnLabel, Timestamp x) throws SQLException {
public void updateBlob(String columnLabel, InputStream x, long length) update(columnLabel, x);
throws SQLException {
throw getUnsupportedException();
} }
//*/
// ---- result set meta data ---------------------------------------------
/** /**
* INTERNAL * Returns the column count.
*
* @return the column count
*/ */
//## Java 1.6 ## public int getColumnCount() {
public void updateCharacterStream(int columnIndex, Reader x) return columns.size();
throws SQLException {
throw getUnsupportedException();
} }
//*/
/** /**
* INTERNAL * Returns 15.
*
* @param columnIndex (1,2,...)
* @return 15
*/ */
//## Java 1.6 ## public int getColumnDisplaySize(int columnIndex) {
public void updateCharacterStream(String columnLabel, Reader x) return 15;
throws SQLException {
throw getUnsupportedException();
} }
//*/
/** /**
* INTERNAL * Returns the SQL type.
*
* @param columnIndex (1,2,...)
* @return the SQL type
*/ */
//## Java 1.6 ## public int getColumnType(int columnIndex) throws SQLException {
public void updateCharacterStream(int columnIndex, Reader x, long length) return getColumn(columnIndex - 1).sqlType;
throws SQLException {
throw getUnsupportedException();
} }
//*/
/** /**
* INTERNAL * Returns the precision.
*
* @param columnIndex (1,2,...)
* @return the precision
*/ */
//## Java 1.6 ## public int getPrecision(int columnIndex) throws SQLException {
public void updateCharacterStream(String columnLabel, Reader x, long length) return getColumn(columnIndex - 1).precision;
throws SQLException {
throw getUnsupportedException();
} }
//*/
/** /**
* INTERNAL * Returns the scale.
*
* @param columnIndex (1,2,...)
* @return the scale
*/ */
//## Java 1.6 ## public int getScale(int columnIndex) throws SQLException {
public void updateClob(int columnIndex, Reader x) throws SQLException { return getColumn(columnIndex - 1).scale;
throw getUnsupportedException();
} }
//*/
/** /**
* INTERNAL * Returns ResultSetMetaData.columnNullableUnknown.
*
* @param columnIndex (1,2,...)
* @return columnNullableUnknown
*/ */
//## Java 1.6 ## public int isNullable(int columnIndex) {
public void updateClob(String columnLabel, Reader x) throws SQLException { return ResultSetMetaData.columnNullableUnknown;
throw getUnsupportedException();
} }
//*/
/** /**
* INTERNAL * Returns false.
*
* @param columnIndex (1,2,...)
* @return false
*/ */
//## Java 1.6 ## public boolean isAutoIncrement(int columnIndex) {
public void updateClob(int columnIndex, Reader x, long length) return false;
throws SQLException {
throw getUnsupportedException();
} }
//*/
/** /**
* INTERNAL * Returns true.
*
* @param columnIndex (1,2,...)
* @return true
*/ */
//## Java 1.6 ## public boolean isCaseSensitive(int columnIndex) {
public void updateClob(String columnLabel, Reader x, long length) return true;
throws SQLException {
throw getUnsupportedException();
} }
//*/
/** /**
* INTERNAL * Returns false.
*
* @param columnIndex (1,2,...)
* @return false
*/ */
//## Java 1.6 ## public boolean isCurrency(int columnIndex) {
public void updateNCharacterStream(int columnIndex, Reader x) return false;
throws SQLException {
throw getUnsupportedException();
} }
//*/
/** /**
* INTERNAL * Returns false.
*
* @param columnIndex (1,2,...)
* @return false
*/ */
//## Java 1.6 ## public boolean isDefinitelyWritable(int columnIndex) {
public void updateNCharacterStream(String columnLabel, Reader x) return false;
throws SQLException {
throw getUnsupportedException();
} }
//*/
/** /**
* INTERNAL * Returns true.
*
* @param columnIndex (1,2,...)
* @return true
*/ */
//## Java 1.6 ## public boolean isReadOnly(int columnIndex) {
public void updateNCharacterStream(int columnIndex, Reader x, long length) return true;
throws SQLException {
throw getUnsupportedException();
} }
//*/
/** /**
* INTERNAL * Returns true.
*
* @param columnIndex (1,2,...)
* @return true
*/ */
//## Java 1.6 ## public boolean isSearchable(int columnIndex) {
public void updateNCharacterStream(String columnLabel, Reader x, long length) return true;
throws SQLException {
throw getUnsupportedException();
} }
//*/
/** /**
* INTERNAL * Returns true.
*
* @param columnIndex (1,2,...)
* @return true
*/ */
//## Java 1.6 ## public boolean isSigned(int columnIndex) {
public void updateNClob(int columnIndex, Reader x) throws SQLException { return true;
throw getUnsupportedException();
} }
//*/
/** /**
* INTERNAL * Returns false.
*
* @param columnIndex (1,2,...)
* @return false
*/ */
//## Java 1.6 ## public boolean isWritable(int columnIndex) {
public void updateNClob(String columnLabel, Reader x) throws SQLException { return false;
throw getUnsupportedException();
} }
//*/
/** /**
* INTERNAL * Returns null.
*
* @param columnIndex (1,2,...)
* @return null
*/
public String getCatalogName(int columnIndex) {
return null;
}
/**
* Returns the Java class name if this column.
*
* @param columnIndex (1,2,...)
* @return the class name
*/
public String getColumnClassName(int columnIndex) throws SQLException {
int sqlType = getColumn(columnIndex - 1).sqlType;
int type = DataType.convertSQLTypeToValueType(sqlType);
return DataType.getTypeClassName(type);
}
/**
* Returns the column label.
*
* @param columnIndex (1,2,...)
* @return the column label
*/
public String getColumnLabel(int columnIndex) throws SQLException {
return getColumn(columnIndex - 1).name;
}
/**
* Returns the column name.
*
* @param columnIndex (1,2,...)
* @return the column name
*/
public String getColumnName(int columnIndex) throws SQLException {
return getColumnLabel(columnIndex);
}
/**
* Returns the data type name of a column.
*
* @param columnIndex (1,2,...)
* @return the type name
*/ */
//## Java 1.6 ## public String getColumnTypeName(int columnIndex) throws SQLException {
public void updateNClob(int columnIndex, Reader x, long length) int sqlType = getColumn(columnIndex - 1).sqlType;
throws SQLException { int type = DataType.convertSQLTypeToValueType(sqlType);
throw getUnsupportedException(); return DataType.getDataType(type).name;
} }
//*/
/** /**
* INTERNAL * Returns null.
*
* @param columnIndex (1,2,...)
* @return null
*/ */
//## Java 1.6 ## public String getSchemaName(int columnIndex) {
public void updateNClob(String columnLabel, Reader x, long length) return null;
throws SQLException {
throw getUnsupportedException();
} }
//*/
/** /**
* INTERNAL * Returns null.
*
* @param columnIndex (1,2,...)
* @return null
*/ */
public Time getTime(int columnIndex, Calendar cal) throws SQLException { public String getTableName(int columnIndex) {
throw getUnsupportedException(); return null;
} }
// ---- unsupported / result set ---------------------------------------------
/** /**
* INTERNAL * INTERNAL
*/ */
...@@ -1901,20 +2117,6 @@ public class SimpleResultSet implements ResultSet, ResultSetMetaData { ...@@ -1901,20 +2117,6 @@ public class SimpleResultSet implements ResultSet, ResultSetMetaData {
throw getUnsupportedException(); throw getUnsupportedException();
} }
/**
* INTERNAL
*/
public InputStream getAsciiStream(int columnIndex) {
return null;
}
/**
* @deprecated INTERNAL
*/
public InputStream getUnicodeStream(int columnIndex) {
return null;
}
/** /**
* INTERNAL * INTERNAL
*/ */
...@@ -1922,106 +2124,17 @@ public class SimpleResultSet implements ResultSet, ResultSetMetaData { ...@@ -1922,106 +2124,17 @@ public class SimpleResultSet implements ResultSet, ResultSetMetaData {
throw getUnsupportedException(); throw getUnsupportedException();
} }
/** // --- private -----------------------------
* @deprecated INTERNAL
*/
public BigDecimal getBigDecimal(int columnIndex, int scale) throws SQLException {
throw getUnsupportedException();
}
/**
* INTERNAL
*/
public Ref getRef(int columnIndex) throws SQLException {
throw getUnsupportedException();
}
/**
* INTERNAL
*/
public InputStream getAsciiStream(String columnLabel) throws SQLException {
throw getUnsupportedException();
}
/**
* @deprecated INTERNAL
*/
public InputStream getUnicodeStream(String columnLabel) throws SQLException {
throw getUnsupportedException();
}
/**
* INTERNAL
*/
public Object getObject(int columnIndex, Map<String, Class<?>> map) throws SQLException {
throw getUnsupportedException();
}
/**
* @deprecated INTERNAL
*/
public BigDecimal getBigDecimal(String columnLabel, int scale) throws SQLException {
throw getUnsupportedException();
}
/**
* INTERNAL
*/
public URL getURL(String columnLabel) throws SQLException {
throw getUnsupportedException();
}
/**
* INTERNAL
*/
public Date getDate(int columnIndex, Calendar cal) throws SQLException {
throw getUnsupportedException();
}
/**
* INTERNAL
*/
public Ref getRef(String colName) throws SQLException {
throw getUnsupportedException();
}
/**
* INTERNAL
*/
public Timestamp getTimestamp(int columnIndex, Calendar cal) throws SQLException {
throw getUnsupportedException();
}
/**
* INTERNAL
*/
public Object getObject(String colName, Map<String, Class<?>> map) throws SQLException {
throw getUnsupportedException();
}
/**
* INTERNAL
*/
public Date getDate(String columnLabel, Calendar cal) throws SQLException {
throw getUnsupportedException();
}
/** private void update(int columnIndex, Object obj) throws SQLException {
* INTERNAL checkColumnIndex(columnIndex);
*/ this.currentRow[columnIndex - 1] = obj;
public Time getTime(String columnLabel, Calendar cal) throws SQLException {
throw getUnsupportedException();
} }
/** private void update(String columnLabel, Object obj) throws SQLException {
* INTERNAL this.currentRow[findColumn(columnLabel) - 1] = obj;
*/
public Timestamp getTimestamp(String columnLabel, Calendar cal) throws SQLException {
throw getUnsupportedException();
} }
// --- private -----------------------------
/** /**
* INTERNAL * INTERNAL
*/ */
...@@ -2030,8 +2143,8 @@ public class SimpleResultSet implements ResultSet, ResultSetMetaData { ...@@ -2030,8 +2143,8 @@ public class SimpleResultSet implements ResultSet, ResultSetMetaData {
} }
private void checkColumnIndex(int columnIndex) throws SQLException { private void checkColumnIndex(int columnIndex) throws SQLException {
if (columnIndex < 0 || columnIndex >= columns.size()) { if (columnIndex < 1 || columnIndex > columns.size()) {
throw DbException.getInvalidValueException("columnIndex", columnIndex + 1).getSQLException(); throw DbException.getInvalidValueException("columnIndex", columnIndex).getSQLException();
} }
} }
...@@ -2039,36 +2152,18 @@ public class SimpleResultSet implements ResultSet, ResultSetMetaData { ...@@ -2039,36 +2152,18 @@ public class SimpleResultSet implements ResultSet, ResultSetMetaData {
if (currentRow == null) { if (currentRow == null) {
throw DbException.get(ErrorCode.NO_DATA_AVAILABLE).getSQLException(); throw DbException.get(ErrorCode.NO_DATA_AVAILABLE).getSQLException();
} }
columnIndex--;
checkColumnIndex(columnIndex); checkColumnIndex(columnIndex);
columnIndex--;
Object o = columnIndex < currentRow.length ? currentRow[columnIndex] : null; Object o = columnIndex < currentRow.length ? currentRow[columnIndex] : null;
wasNull = o == null; wasNull = o == null;
return o; return o;
} }
private Column getColumn(int i) throws SQLException { private Column getColumn(int i) throws SQLException {
checkColumnIndex(i); checkColumnIndex(i + 1);
return columns.get(i); return columns.get(i);
} }
/**
* INTERNAL
*/
//## Java 1.6 ##
public RowId getRowId(int columnIndex) throws SQLException {
throw getUnsupportedException();
}
//*/
/**
* INTERNAL
*/
//## Java 1.6 ##
public RowId getRowId(String columnLabel) throws SQLException {
throw getUnsupportedException();
}
//*/
/** /**
* Returns the current result set holdability. * Returns the current result set holdability.
* *
...@@ -2087,79 +2182,6 @@ public class SimpleResultSet implements ResultSet, ResultSetMetaData { ...@@ -2087,79 +2182,6 @@ public class SimpleResultSet implements ResultSet, ResultSetMetaData {
return rows == null; return rows == null;
} }
/**
* INTERNAL
*/
//## Java 1.6 ##
public NClob getNClob(int columnIndex) throws SQLException {
throw getUnsupportedException();
}
//*/
/**
* INTERNAL
*/
//## Java 1.6 ##
public NClob getNClob(String columnLabel) throws SQLException {
throw getUnsupportedException();
}
//*/
/**
* INTERNAL
*/
//## Java 1.6 ##
public SQLXML getSQLXML(int columnIndex) throws SQLException {
throw getUnsupportedException();
}
//*/
/**
* INTERNAL
*/
//## Java 1.6 ##
public SQLXML getSQLXML(String columnLabel) throws SQLException {
throw getUnsupportedException();
}
//*/
/**
* INTERNAL
*/
//## Java 1.6 ##
public String getNString(int columnIndex) throws SQLException {
return getString(columnIndex);
}
//*/
/**
* INTERNAL
*/
//## Java 1.6 ##
public String getNString(String columnLabel) throws SQLException {
return getString(columnLabel);
}
//*/
/**
* INTERNAL
*/
//## Java 1.6 ##
public Reader getNCharacterStream(int columnIndex) throws SQLException {
throw getUnsupportedException();
}
//*/
/**
* INTERNAL
*/
//## Java 1.6 ##
public Reader getNCharacterStream(String columnLabel)
throws SQLException {
throw getUnsupportedException();
}
//*/
/** /**
* INTERNAL * INTERNAL
*/ */
...@@ -2178,30 +2200,6 @@ public class SimpleResultSet implements ResultSet, ResultSetMetaData { ...@@ -2178,30 +2200,6 @@ public class SimpleResultSet implements ResultSet, ResultSetMetaData {
} }
//*/ //*/
/**
* INTERNAL
*
* @param columnIndex the column index (1, 2, ...)
* @param type the class of the returned value
*/
/*## Java 1.7 ##
public <T> T getObject(int columnIndex, Class<T> type) {
return null;
}
//*/
/**
* INTERNAL
*
* @param columnName the column name
* @param type the class of the returned value
*/
/*## Java 1.7 ##
public <T> T getObject(String columnName, Class<T> type) {
return null;
}
//*/
/** /**
* Set the auto-close behavior. If enabled (the default), the result set is * Set the auto-close behavior. If enabled (the default), the result set is
* closed after reading the last row. * closed after reading the last row.
......
...@@ -339,37 +339,78 @@ public class TestTools extends TestBase { ...@@ -339,37 +339,78 @@ public class TestTools extends TestBase {
assertNull(rs.getBinaryStream(12)); assertNull(rs.getBinaryStream(12));
assertTrue(rs.wasNull()); assertTrue(rs.wasNull());
// all 'updateX' methods are not supported // all updateX methods
for (Method m: rs.getClass().getMethods()) { for (Method m: rs.getClass().getMethods()) {
if (m.getName().startsWith("update")) { if (m.getName().startsWith("update")) {
if (m.getName().equals("updateRow")) {
continue;
}
int len = m.getParameterTypes().length; int len = m.getParameterTypes().length;
Object[] params = new Object[len]; Object[] params = new Object[len];
int i = 0; int i = 0;
String expectedValue = null;
for (Class<?> type : m.getParameterTypes()) { for (Class<?> type : m.getParameterTypes()) {
Object o = null; Object o;
String e = null;
if (type == int.class) { if (type == int.class) {
o = 1; o = 1;
e = "1";
} else if (type == byte.class) { } else if (type == byte.class) {
o = (byte) 1; o = (byte) 2;
e = "2";
} else if (type == double.class) { } else if (type == double.class) {
o = (double) 1; o = (double) 3;
e = "3.0";
} else if (type == float.class) { } else if (type == float.class) {
o = (float) 1; o = (float) 4;
e = "4.0";
} else if (type == long.class) { } else if (type == long.class) {
o = (long) 1; o = (long) 5;
e = "5";
} else if (type == short.class) { } else if (type == short.class) {
o = (short) 1; o = (short) 6;
e = "6";
} else if (type == boolean.class) { } else if (type == boolean.class) {
o = false; o = false;
e = "false";
} else if (type == String.class) {
// columnName or value
o = "a";
e = "a";
} else {
o = null;
}
if (i == 1) {
expectedValue = e;
} }
params[i] = o; params[i] = o;
i++; i++;
} }
m.invoke(rs, params);
if (params.length == 1) {
// updateNull
assertEquals(null, rs.getString(1));
} else {
assertEquals(expectedValue, rs.getString(1));
}
// invalid column name / index
Object invalidColumn;
if (m.getParameterTypes()[0] == String.class) {
invalidColumn = "x";
} else {
invalidColumn = 0;
}
params[0] = invalidColumn;
try { try {
m.invoke(rs, params); m.invoke(rs, params);
fail();
} catch (InvocationTargetException e) { } catch (InvocationTargetException e) {
SQLException e2 = (SQLException) e.getTargetException(); SQLException e2 = (SQLException) e.getTargetException();
assertEquals(ErrorCode.FEATURE_NOT_SUPPORTED_1, e2.getErrorCode()); if (invalidColumn instanceof String) {
assertEquals(ErrorCode.COLUMN_NOT_FOUND_1, e2.getErrorCode());
} else {
assertEquals(ErrorCode.INVALID_VALUE_2, e2.getErrorCode());
}
} }
} }
} }
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论