📄 resultset.java
字号:
* @param columnName is the SQL name of the column
*
* @return a Object holding the column value
*
* @exception java.sql.SQLException if a database access error occurs
*/
public Object getObject(String columnName) throws java.sql.SQLException {
return getObject(findColumn(columnName));
}
/**
* JDBC 2.0 Returns the value of column i as a Java object. Use the map to
* determine the class from which to construct data of SQL structured and
* distinct types.
*
* @param i the first column is 1, the second is 2, ...
* @param map the mapping from SQL type names to Java classes
*
* @return an object representing the SQL value
*
* @throws SQLException because this is not implemented
*/
public Object getObject(int i, java.util.Map map) throws SQLException {
return getObject(i);
}
/**
* JDBC 2.0 Returns the value of column i as a Java object. Use the map to
* determine the class from which to construct data of SQL structured and
* distinct types.
*
* @param colName the column name
* @param map the mapping from SQL type names to Java classes
*
* @return an object representing the SQL value
*
* @throws SQLException as this is not implemented
*/
public Object getObject(String colName, java.util.Map map)
throws SQLException {
return getObject(findColumn(colName), map);
}
/**
* JDBC 2.0 Get a REF(<structured-type>) column.
*
* @param i the first column is 1, the second is 2, ...
*
* @return an object representing data of an SQL REF type
*
* @throws SQLException as this is not implemented
* @throws NotImplemented DOCUMENT ME!
*/
public java.sql.Ref getRef(int i) throws SQLException {
throw new NotImplemented();
}
/**
* JDBC 2.0 Get a REF(<structured-type>) column.
*
* @param colName the column name
*
* @return an object representing data of an SQL REF type
*
* @throws SQLException as this method is not implemented.
* @throws NotImplemented DOCUMENT ME!
*/
public java.sql.Ref getRef(String colName) throws SQLException {
throw new NotImplemented();
}
/**
* JDBC 2.0
*
* <p>
* Determine the current row number. The first row is number 1, the second
* number 2, etc.
* </p>
*
* @return the current row number, else return 0 if there is no current row
*
* @exception SQLException if a database-access error occurs.
*/
public int getRow() throws SQLException {
if (Driver.TRACE) {
Object[] args = { };
Debug.methodCall(this, "getRow", args);
}
int currentRow = rowData.getCurrentRowNumber();
int row = 0;
// Non-dynamic result sets can be interrogated
// for this information
if (!rowData.isDynamic()) {
if ((currentRow < 0) || rowData.isAfterLast() || rowData.isEmpty()) {
row = 0;
} else {
row = currentRow + 1;
}
} else {
// dynamic (streaming) can not
row = currentRow + 1;
}
if (Driver.TRACE) {
Debug.returnValue(this, "getRow", new Integer(row));
}
if (Driver.TRACE) {
Debug.returnValue(this, "getRow", new Integer(row));
}
return row;
}
/**
* Get the value of a column in the current row as a Java short.
*
* @param columnIndex the first column is 1, the second is 2,...
*
* @return the column value; 0 if SQL NULL
*
* @exception java.sql.SQLException if a database access error occurs
* @throws SQLException DOCUMENT ME!
*/
public short getShort(int columnIndex) throws java.sql.SQLException {
checkRowPos();
String val = null;
try {
val = getString(columnIndex);
if ((val != null) && (val.length() != 0)) {
if ((val.indexOf("e") == -1) && (val.indexOf("E") == -1)
&& (val.indexOf(".") == -1)) {
return Short.parseShort(val);
} else {
// Convert floating point
return (short) (Double.parseDouble(val));
}
} else {
return 0;
}
} catch (NumberFormatException nfe) {
try {
// To do: warn on under/overflow?
return (short) Double.parseDouble(val);
} catch (NumberFormatException newNfe) {
; // ignore, it's not a number
}
throw new SQLException("Invalid value for getShort() - '" + val
+ "'", SQLError.SQL_STATE_ILLEGAL_ARGUMENT);
}
}
/**
* DOCUMENT ME!
*
* @param columnName DOCUMENT ME!
*
* @return DOCUMENT ME!
*
* @throws java.sql.SQLException DOCUMENT ME!
*/
public short getShort(String columnName) throws java.sql.SQLException {
return getShort(findColumn(columnName));
}
/**
* JDBC 2.0 Return the Statement that produced the ResultSet.
*
* @return the Statment that produced the result set, or null if the result
* was produced some other way.
*
* @exception SQLException if a database-access error occurs
*/
public java.sql.Statement getStatement() throws SQLException {
return (java.sql.Statement) owningStatement;
}
/**
* Get the value of a column in the current row as a Java String
*
* @param columnIndex the first column is 1, the second is 2...
*
* @return the column value, null for SQL NULL
*
* @exception java.sql.SQLException if a database access error occurs
* @throws SQLException DOCUMENT ME!
*/
public String getString(int columnIndex) throws java.sql.SQLException {
checkRowPos();
if (fields == null) {
throw new java.sql.SQLException("Query generated no fields for ResultSet",
SQLError.SQL_STATE_INVALID_COLUMN_NUMBER);
}
try {
if (thisRow[columnIndex - 1] == null) {
wasNullFlag = true;
return null;
} else {
wasNullFlag = false;
}
} catch (NullPointerException E) {
wasNullFlag = true;
return null;
} catch (ArrayIndexOutOfBoundsException aioobEx) {
throw new java.sql.SQLException("Column Index out of range ( "
+ columnIndex + " > " + fields.length + ").", SQLError.SQL_STATE_INVALID_COLUMN_NUMBER);
}
String stringVal = null;
columnIndex--; // JDBC is 1-based, Java is not !?
if ((connection != null) && connection.useUnicode()) {
try {
String encoding = this.fields[columnIndex].getCharacterSet();
if (encoding == null) {
stringVal = new String(thisRow[columnIndex]);
} else {
SingleByteCharsetConverter converter = this.connection.getCharsetConverter(encoding);
if (converter != null) {
stringVal = converter.toString(thisRow[columnIndex]);
} else {
stringVal = new String(thisRow[columnIndex], encoding);
}
}
} catch (java.io.UnsupportedEncodingException E) {
throw new SQLException("Unsupported character encoding '"
+ connection.getEncoding() + "'.", SQLError.SQL_STATE_GENERAL_ERROR);
}
} else {
stringVal = StringUtils.toAsciiString(thisRow[columnIndex]);
}
return stringVal;
}
/**
* The following routines simply convert the columnName into a columnIndex
* and then call the appropriate routine above.
*
* @param columnName is the SQL name of the column
*
* @return the column value
*
* @exception java.sql.SQLException if a database access error occurs
*/
public String getString(String columnName) throws java.sql.SQLException {
return getString(findColumn(columnName));
}
/**
* Get the value of a column in the current row as a java.sql.Time object
*
* @param columnIndex the first column is 1, the second is 2...
*
* @return the column value; null if SQL NULL
*
* @throws java.sql.SQLException if a database access error occurs
*/
public synchronized Time getTime(int columnIndex) throws java.sql.SQLException {
return getTimeInternal(columnIndex, this.defaultTimeZone);
}
/**
* Get the value of a column in the current row as a java.sql.Time object.
*
* @param columnName is the SQL name of the column
*
* @return the column value; if the value is SQL NULL, the result is null
*
* @throws java.sql.SQLException if a database-access error occurs.
*/
public Time getTime(String columnName) throws java.sql.SQLException {
return getTime(findColumn(columnName));
}
/**
* Get the value of a column in the current row as a java.sql.Time object.
* Use the calendar to construct an appropriate millisecond value for the
* Time, if the underlying database doesn't store timezone information.
*
* @param columnIndex the first column is 1, the second is 2, ...
* @param cal the calendar to use in constructing the time
*
* @return the column value; if the value is SQL NULL, the result is null
*
* @exception SQLException if a database-access error occurs.
*/
public java.sql.Time getTime(int columnIndex, Calendar cal)
throws SQLException {
return getTimeInternal(columnIndex, cal.getTimeZone());
}
/**
* Get the value of a column in the current row as a java.sql.Time object.
* Use the calendar to construct an appropriate millisecond value for the
* Time, if the underlying database doesn't store timezone information.
*
* @param columnName is the SQL name of the column
* @param cal the calendar to use in constructing the time
*
* @return the column value; if the value is SQL NULL, the result is null
*
* @exception SQLException if a database-access error occurs.
*/
public java.sql.Time getTime(String columnName, Calendar cal)
throws SQLException {
return getTime(findColumn(columnName), cal);
}
/**
* Get the value of a column in the current row as a java.sql.Timestamp
* object
*
* @param columnIndex the first column is 1, the second is 2...
*
* @return the column value; null if SQL NULL
*
* @exception java.sql.SQLException if a database access error occurs
*/
public synchronized Timestamp getTimestamp(int columnIndex) throws java.sql.SQLException {
return getTimestampInternal(columnIndex, this.defaultTimeZone);
}
/**
* DOCUMENT ME!
*
* @param columnName DOCUMENT ME!
*
* @return DOCUMENT ME!
*
* @throws java.sql.SQLException DOCUMENT ME!
*/
public Timestamp getTimestamp(String columnName)
throws java.sql.SQLException {
return getTimestamp(findColumn(columnName));
}
/**
* Get the value of a column in the current row as a java.sql.Timestamp
* object. Use the calendar to construct an appropriate millisecond value
* for the Timestamp, if the underlying database doesn't store timezone
* information.
*
* @param columnIndex the first column is 1, the second is 2, ...
* @param cal the calendar to use in constructing the timestamp
*
* @return the column value; if the value is SQL NULL, the result is null
*
* @exception SQLException if a database-access error occurs.
*/
public java.sql.Timestamp getTimestamp(int columnIndex, Calendar cal)
throws SQLException {
return getTimestampInternal(columnIndex, cal.getTimeZone());
}
/**
* Get the value of a column in the current row as a java.sql.Timestamp
* object. Use the calendar to construct an appropriate millisecond value
* for the Timestamp, if the underlying database doesn't store timezone
* information.
*
* @param columnName is the SQL name of the column
* @param cal the calendar to use in constructing the timestamp
*
* @return the column value; if the value is SQL NULL, the result is null
*
* @exception SQLException if a database-access error occurs.
*/
public java.sql.Timestamp getTimestamp(String columnName, Calendar cal)
throws SQLException {
return getTimestamp(findColumn(columnName), cal);
}
/**
* JDBC 2.0 Return the type of this result set. The type is determined
* based on the statement that created the result set.
*
* @return TYPE_FORWARD_ONLY, TYPE_SCROLL_INSENSITIVE, or
* TYPE_SCROLL_SENSITIVE
*
* @excepti
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -