📄 csvresultset.java
字号:
* of this <code>ResultSet</code> object as
* a <code>java.sql.BigDecimal</code> in the Java programming language.
*
* @param columnIndex the first column is 1, the second is 2, ...
* @param scale the number of digits to the right of the decimal point
* @return the column value; if the value is SQL <code>NULL</code>, the
* value returned is <code>null</code>
* @exception SQLException if a database access error occurs
* @deprecated
*/
public BigDecimal getBigDecimal(int columnIndex, int scale)
throws SQLException {
// let getBigDecimal(int) handle this for now
return getBigDecimal(columnIndex);
}
/**
* Retrieves the value of the designated column in the current row
* of this <code>ResultSet</code> object as
* a <code>byte</code> array in the Java programming language.
* The bytes represent the raw values returned by the driver.
*
* @param columnIndex the first column is 1, the second is 2, ...
* @return the column value; if the value is SQL <code>NULL</code>, the
* value returned is <code>null</code>
* @exception SQLException if a database access error occurs
*/
public byte[] getBytes(int columnIndex) throws SQLException {
String str = getString(columnIndex);
return (str == null) ? null : str.getBytes();
}
/**
* Retrieves the value of the designated column in the current row
* of this <code>ResultSet</code> object as
* a <code>java.sql.Date</code> object in the Java programming language.
*
* @param columnIndex the first column is 1, the second is 2, ...
* @return the column value; if the value is SQL <code>NULL</code>, the
* value returned is <code>null</code>
* @exception SQLException if a database access error occurs
*/
public Date getDate(int columnIndex) throws SQLException {
String str = getString(columnIndex);
return (str == null) ? null : Date.valueOf(str);
}
/**
* Retrieves the value of the designated column in the current row
* of this <code>ResultSet</code> object as
* a <code>java.sql.Time</code> object in the Java programming language.
*
* @param columnIndex the first column is 1, the second is 2, ...
* @return the column value; if the value is SQL <code>NULL</code>, the
* value returned is <code>null</code>
* @exception SQLException if a database access error occurs
*/
public Time getTime(int columnIndex) throws SQLException {
String str = getString(columnIndex);
return (str == null) ? null : Time.valueOf(str);
}
/**
* Retrieves the value of the designated column in the current row
* of this <code>ResultSet</code> object as a
* <code>java.sql.Timestamp</code> object in the Java programming language.
*
* @param columnIndex the first column is 1, the second is 2, ...
* @return the column value; if the value is SQL <code>NULL</code>, the
* value returned is <code>null</code>
* @exception SQLException if a database access error occurs
*/
public Timestamp getTimestamp(int columnIndex) throws SQLException {
String str = getString(columnIndex);
return (str == null) ? null : Timestamp.valueOf(str);
}
/**
* Retrieves the value of the designated column in the current row
* of this <code>ResultSet</code> object as a stream of ASCII characters.
* The value can then be read in chunks from the stream. This method is
* particularly suitable for retrieving large <char>LONGVARCHAR</char>
* values. The JDBC driver will do any necessary conversion from the
* database format into ASCII.
*
* <P><B>Note:</B> All the data in the returned stream must be
* read prior to getting the value of any other column. The next
* call to a getter method implicitly closes the stream. Also, a
* stream may return <code>0</code> when the method
* <code>InputStream.available</code>
* is called whether there is data available or not.
*
* @param columnIndex the first column is 1, the second is 2, ...
* @return a Java input stream that delivers the database column value
* as a stream of one-byte ASCII characters;
* if the value is SQL <code>NULL</code>, the
* value returned is <code>null</code>
* @exception SQLException if a database access error occurs
*/
public InputStream getAsciiStream(int columnIndex) throws SQLException {
String str = getString(columnIndex);
is = new ByteArrayInputStream(str.getBytes());
return (str == null) ? null : is;
}
/**
* Retrieves the value of the designated column in the current row
* of this <code>ResultSet</code> object as
* as a stream of two-byte Unicode characters. The first byte is
* the high byte; the second byte is the low byte.
*
* The value can then be read in chunks from the
* stream. This method is particularly
* suitable for retrieving large <code>LONGVARCHAR</code>values. The
* JDBC driver will do any necessary conversion from the database
* format into Unicode.
*
* <P><B>Note:</B> All the data in the returned stream must be
* read prior to getting the value of any other column. The next
* call to a getter method implicitly closes the stream.
* Also, a stream may return <code>0</code> when the method
* <code>InputStream.available</code>
* is called, whether there is data available or not.
*
* @param columnIndex the first column is 1, the second is 2, ...
* @return a Java input stream that delivers the database column value
* as a stream of two-byte Unicode characters;
* if the value is SQL <code>NULL</code>, the value returned is
* <code>null</code>
*
* @exception SQLException if a database access error occurs
* @deprecated use <code>getCharacterStream</code> in place of
* <code>getUnicodeStream</code>
*/
public InputStream getUnicodeStream(int columnIndex) throws SQLException {
// delegate to getAsciiStream(int)
return getAsciiStream(columnIndex);
}
/**
* Retrieves the value of the designated column in the current row
* of this <code>ResultSet</code> object as a binary stream of
* uninterpreted bytes. The value can then be read in chunks from the
* stream. This method is particularly
* suitable for retrieving large <code>LONGVARBINARY</code> values.
*
* <P><B>Note:</B> All the data in the returned stream must be
* read prior to getting the value of any other column. The next
* call to a getter method implicitly closes the stream. Also, a
* stream may return <code>0</code> when the method
* <code>InputStream.available</code>
* is called whether there is data available or not.
*
* @param columnIndex the first column is 1, the second is 2, ...
* @return a Java input stream that delivers the database column value
* as a stream of uninterpreted bytes;
* if the value is SQL <code>NULL</code>, the value returned is
* <code>null</code>
* @exception SQLException if a database access error occurs
*/
public InputStream getBinaryStream(int columnIndex) throws SQLException {
// delegate to getAsciiStream(int)
return getAsciiStream(columnIndex);
}
//======================================================================
// Methods for accessing results by column name
//======================================================================
/**
* Retrieves the value of the designated column in the current row
* of this <code>ResultSet</code> object as
* a <code>String</code> in the Java programming language.
*
* @param columnName the SQL name of the column
* @return the column value; if the value is SQL <code>NULL</code>, the
* value returned is <code>null</code>
* @exception SQLException if a database access error occurs
*/
public String getString(String columnName) throws SQLException {
// perform pre-accessor method processing
preAccessor(columnName);
// use CsvReader.getColumn(String) to retrieve the column
return reader.getColumn(columnName);
}
/**
* Retrieves the value of the designated column in the current row
* of this <code>ResultSet</code> object as
* a <code>boolean</code> in the Java programming language.
*
* @param columnName the SQL name of the column
* @return the column value; if the value is SQL <code>NULL</code>, the
* value returned is <code>false</code>
* @exception SQLException if a database access error occurs
*/
public boolean getBoolean(String columnName) throws SQLException {
String str = getString(columnName);
return (str == null) ? false : Boolean.valueOf(str).booleanValue();
}
/**
* Retrieves the value of the designated column in the current row
* of this <code>ResultSet</code> object as
* a <code>byte</code> in the Java programming language.
*
* @param columnName the SQL name of the column
* @return the column value; if the value is SQL <code>NULL</code>, the
* value returned is <code>0</code>
* @exception SQLException if a database access error occurs
*/
public byte getByte(String columnName) throws SQLException {
String str = getString(columnName);
return (str == null) ? 0 : Byte.parseByte(str);
}
/**
* Retrieves the value of the designated column in the current row
* of this <code>ResultSet</code> object as
* a <code>short</code> in the Java programming language.
*
* @param columnName the SQL name of the column
* @return the column value; if the value is SQL <code>NULL</code>, the
* value returned is <code>0</code>
* @exception SQLException if a database access error occurs
*/
public short getShort(String columnName) throws SQLException {
String str = getString(columnName);
return (str == null) ? 0 : Short.parseShort(str);
}
/**
* Gets the value of the designated column in the current row
* of this <code>ResultSet</code> object as
* an <code>int</code> in the Java programming language.
*
* @param columnName the SQL name of the column
* @return the column value; if the value is SQL <code>NULL</code>, the
* value returned is <code>0</code>
* @exception SQLException if a database access error occurs
*/
public int getInt(String columnName) throws SQLException {
String str = getString(columnName);
return (str == null) ? 0 : Integer.parseInt(str);
}
/**
* Retrieves the value of the designated column in the current row
* of this <code>ResultSet</code> object as
* a <code>long</code> in the Java programming language.
*
* @param columnName the SQL name of the column
* @return the column value; if the value is SQL <code>NULL</code>, the
* value returned is <code>0</code>
* @exception SQLException if a database access error occurs
*/
public long getLong(String columnName) throws SQLException {
String str = getString(columnName);
return (str == null) ? 0L : Long.parseLong(str);
}
/**
* Gets the value of the designated column in the current row
* of this <code>ResultSet</code> object as
* a <code>float</code> in the Java programming language.
*
* @param columnName the SQL name of the column
* @return the column value; if the value is SQL <code>NULL</code>, the
* value returned is <code>0</code>
* @exception SQLException if a database access error occurs
*/
public float getFloat(String columnName) throws SQLException {
String str = getString(columnName);
return (str == null) ? 0F : Float.parseFloat(str);
}
/**
* Retrieves the value of the designated column in the current row
* of this <code>ResultSet</code> object as
* a <code>double</code> in the Java programming language.
*
* @param columnName the SQL name of the column
* @return the column value; if the value is SQL <code>NULL</code>, the
* value returned is <code>0</code>
* @exception SQLException if a database access error occurs
*/
public double getDouble(String columnName) throws SQLException {
String str = getString(columnName);
return (str == null) ? 0D : Double.parseDouble(str);
}
/**
* Retrieves the value of the designated column in the current row
* of this <code>ResultSet</code> object as
* a <code>java.math.BigDecimal</code> in the Java programming language.
*
* @param columnName the SQL name of the column
* @param scale the number of digits to the right of the decimal point
* @return the column value; if the value is SQL <code>NULL</code>, the
* value returned is <code>null</code>
* @exception SQLException if a database access error occurs
* @deprecated
*/
public BigDecimal getBigDecimal(String columnName, int scale)
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -