?? tinysqlresultset.java
字號:
/**
*
* Get the long value of a column by name
* @param columnName is the SQL name of the column
* @return the column value; if isNull the value is 0
*
*/
public long getLong(String columnName) throws SQLException {
return getLong(findColumn(columnName));
}
/**
*
* Get the float value of a column by name
* @param columnName is the SQL name of the column
* @return the column value; if isNull the value is 0
*
*/
public float getFloat(String columnName) throws SQLException {
return getFloat(findColumn(columnName));
}
/**
*
* Get the double value of a named column
* @param columnName is the SQL name of the column
* @return the column value; if isNull the value is 0
*
*/
public double getDouble(String columnName) throws SQLException {
return getDouble(findColumn(columnName));
}
/**
*
* Get the value of a named column as a BigDecimal object
* @param columnName is the SQL name of the column
* @return the column value; if isNull the value is null
* @deprecated
*/
public BigDecimal getBigDecimal(String columnName, int scale) throws SQLException {
return getBigDecimal(findColumn(columnName), scale);
}
/**
*
* Get the value of a named column as a byte array
* @param columnName is the SQL name of the column
* @return the column value; if isNull the value is null
*
*/
public byte[] getBytes(String columnName) throws SQLException {
return getBytes(findColumn(columnName));
}
/**
*
* Get a named column as a java.sql.Date
* @param columnName is the SQL name of the column
* @return the column value; if isNull the value is null
*
*/
public java.sql.Date getDate(String columnName) throws SQLException {
return getDate(findColumn(columnName));
}
/**
*
* Get a named column as a java.sql.Time
* @param columnName is the SQL name of the column
* @return the column value; if isNull the value is null
*
*/
public java.sql.Time getTime(String columnName) throws SQLException {
return getTime(findColumn(columnName));
}
/**
*
* Get a named column as a java.sql.Time
* @param columnName is the SQL name of the column
* @return the column value; if isNull the value is null
*
*/
public java.sql.Timestamp getTimestamp(String columnName)
throws SQLException {
return getTimestamp(findColumn(columnName));
}
/**
*
* This is unsupported, but we'll try to call the corresponding
* call by column index.
*
*/
public java.io.InputStream getAsciiStream(String columnName)
throws SQLException {
return getAsciiStream(findColumn(columnName));
}
/**
*
* This is unsupported, but we'll try to call the corresponding
* call by column index.
* @deprecated
*
*/
public java.io.InputStream getUnicodeStream(String columnName)
throws SQLException {
return getUnicodeStream(findColumn(columnName));
}
/**
*
* This is unsupported, but we'll try to call the corresponding
* call by column index.
*
*/
public java.io.InputStream getBinaryStream(String columnName)
throws SQLException {
return getBinaryStream(findColumn(columnName));
}
/**
*
* Get the value of a named column as an object
* @param columnName the SQL column name
* @param sqlType SQL type code defined by java.sql.Types
* @return the parameter as an Object
*
*/
public Object getObject(String columnName, int sqlType, int scale)
throws SQLException {
return getObject(findColumn(columnName), sqlType, scale);
}
/**
*
* Same as above, except defaulting scale to 0.
*
*/
public Object getObject(String columnName, int type)
throws SQLException {
return getObject(findColumn(columnName), type, 0);
}
/**
*
* Same as above, except returning the default SQL type
*
*/
public Object getObject(String columnName) throws SQLException {
return getObject(findColumn(columnName));
}
/**
*
* Given a column name, this method returns the column number for that
* name. Column name to number mappings are kept inside a Hashtable.
* Applications that do not need the overhead of this calculation are
* not penalized since the mapping only occurs on the first attempt to
* access a column number by name.
* @exception java.sql.SQLException thrown if a bad name is passed
* @param name the name of the column desired
* @return the column number, 1 being the first column
*
*/
public int findColumn(String name) throws SQLException {
Integer num;
// does the column map exist?
//
if( column_map == null ) {
int i, maxi;
String columnIndexName;
// create a Hashtable which expects to hold
// enough objects for all the columns in the
// result set.
//
column_map = new Hashtable(maxi = result.numcols());
// add each column by name, with an Integer index
//
for(i=0; i<maxi; i++) {
tsColumn tsc = result.columnAtIndex(i);
columnIndexName = tsc.name;
if ( tsc.alias != (String)null ) columnIndexName = tsc.alias;
column_map.put(columnIndexName, new Integer(i));
}
}
// one way or another, we've got a column_map; either it
// already existed, or the above code created it.
//
// look up the column name in the map, and find it's
// index (the Integer object)
//
num = (Integer)column_map.get(name);
if( num == null ) {
throw new SQLException("Invalid column name: " + name);
}
// return the column index as an int
//
return num.intValue() + 1;
}
/**
*
* Return the warning chain. This is presently unsupported.
* @see java.sql.Statement#getWarnings
* @return the chain of warnings
*
*/
public SQLWarning getWarnings() throws SQLException {
return null;
}
/**
*
* Clear the chain of warnings. This does nothing, since the
* warning chain is not used by tinySQL
* @see java.sql.Statement#clearWarnings
*
*/
public void clearWarnings() throws SQLException {
}
//--------------------------JDBC 2.0-----------------------------------
//---------------------------------------------------------------------
// Getter's and Setter's
//---------------------------------------------------------------------
/**
* JDBC 2.0
*
* <p>Gets the value of a column in the current row as a java.io.Reader.
* @param columnIndex the first column is 1, the second is 2, ...
*/
public java.io.Reader getCharacterStream(int columnIndex) throws SQLException {
return null;
}
/**
* JDBC 2.0
*
* <p>Gets the value of a column in the current row as a java.io.Reader.
* @param columnName the name of the column
* @return the value in the specified column as a <code>java.io.Reader</code>
*/
public java.io.Reader getCharacterStream(String columnName) throws SQLException {
return null;
}
/**
* JDBC 2.0
*
* Gets the value of a column in the current row as a java.math.BigDecimal
* object with full precision.
*
* @param columnIndex the first column is 1, the second is 2, ...
* @return the column value (full precision); if the value is SQL NULL,
* the result is null
* @exception SQLException if a database access error occurs
*/
public BigDecimal getBigDecimal(int columnIndex) throws SQLException {
return null;
}
/**
* JDBC 2.0
*
* Gets the value of a column in the current row as a java.math.BigDecimal
* object with full precision.
* @param columnName the column name
* @return the column value (full precision); if the value is SQL NULL,
* the result is null
* @exception SQLException if a database access error occurs
*
*/
public BigDecimal getBigDecimal(String columnName) throws SQLException {
return null;
}
//---------------------------------------------------------------------
// Traversal/Positioning
//---------------------------------------------------------------------
/**
* JDBC 2.0
*
* <p>Indicates whether the cursor is before the first row in the result
* set.
*
* @return true if the cursor is before the first row, false otherwise. Returns
* false when the result set contains no rows.
* @exception SQLException if a database access error occurs
*/
public boolean isBeforeFirst() throws SQLException {
return false;
}
/**
* JDBC 2.0
*
* <p>Indicates whether the cursor is after the last row in the result
* set.
*
* @return true if the cursor is after the last row, false otherwise. Returns
* false when the result set contains no rows.
* @exception SQLException if a database access error occurs
*/
public boolean isAfterLast() throws SQLException {
return false;
}
/**
* JDBC 2.0
*
* <p>Indicates whether the cursor is on the first row of the result set.
*
* @return true if the cursor is on the first row, false otherwise.
* @exception SQLException if a database access error occurs
*/
public boolean isFirst() throws SQLException {
return false;
}
/**
* JDBC 2.0
*
* <p>Indicates whether the cursor is on the last row of the result set.
* Note: Calling the method <code>isLast</code> may be expensive
* because the JDBC driver
* might need to fetch ahead one row in order to determine
* whether the current row is the last row in the result set.
*
* @return true if the cursor is on the last row, false otherwise.
* @exception SQLException if a database access error occurs
*/
public boolean isLast() throws SQLException {
return false;
}
/**
* JDBC 2.0
*
* <p>Moves the cursor to the front of the result set, just before the
* first row. Has no effect if the result set contains no rows.
*
* @exception SQLException if a database access error occurs or the
* result set type is TYPE_FORWARD_ONLY
*/
public void beforeFirst() throws SQLException {
return ;
}
/**
* JDBC 2.0
*
* <p>Moves the cursor to the end of the result set, just after the last
* row. Has no effect if the result set contains no rows.
*
* @exception SQLException if a database access error occurs or the
* result set type is TYPE_FORWARD_ONLY
*/
public void afterLast() throws SQLException {
return ;
}
/**
* JDBC 2.0
*
* <p>Moves the cursor to the first row in the result set.
*
* @return true if the cursor is on a valid row; false if
* there are no rows in the result set
* @exception SQLException if a database access error occurs or the
* result set type is TYPE_FORWARD_ONLY
*/
public boolean first() throws SQLException {
return false;
}
/**
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -