In a JDBC ResultSet, what should happen when getLong() or getShort() is called on an int result colu
Posted
by Uri
on Stack Overflow
See other posts from Stack Overflow
or by Uri
Published on 2010-05-13T18:52:24Z
Indexed on
2010/05/13
19:04 UTC
Read the original article
Hit count: 106
Say that I have a JDBC ResultSet, and I call the getLong() or getshort() method.
For which of the following SQL types {SMALLINT, INT, BIGINT} should I get long, and for which types should I get an error?
In other words, if I have an INT and I want a SMALLINT (A short), would I get it, or would I get an error? Similarly, if I have an INT and want a BIGINT (a long), would I get it, or would I get an error?
The Javadocs (listed below) say nothing.
public long getLong(int columnIndex) throws SQLException
Retrieves the value of the designated column in the current row
of this ResultSet object as a long in the Java programming language.
Parameters: columnIndex - the first column is 1, the second is 2, ... Returns: the column value; if the value is SQL NULL, the value returned is 0 Throws: SQLException - if a database access error occurs
© Stack Overflow or respective owner