Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

sqlexception when using getInt()

Status
Not open for further replies.

mcowen

Programmer
Oct 21, 2001
134
0
0
GB
Hi,

I am using a ODBC SQL server driver and am having problems when trying to retrieve an Integer from SQL Server 2000.

workload.next();
itemtime = workload.getTimestamp("DATE_TIME");
itype = workload.getString("TYPE");
System.out.println("itype = " + itype);
int refnum = workload.getInt("REFNUM");

getInt works in other parts of the program - the only difference in this case is that the number is bigger. So I tried getDouble and getLong but still this columns data can not be retrieved. Heres the error....

itype = 1
AnalystImpl:GetWork() Errors
java.sql.SQLException: [Microsoft][ODBC SQL Server Driver]Invalid Descriptor Index
at sun.jdbc.odbc.JdbcOdbc.createSQLException(JdbcOdbc.java:6106)
at sun.jdbc.odbc.JdbcOdbc.standardError(JdbcOdbc.java:6263)
at sun.jdbc.odbc.JdbcOdbc.SQLGetDataDouble(JdbcOdbc.java:3058)
at sun.jdbc.odbc.JdbcOdbcResultSet.getDataDouble(JdbcOdbcResultSet.java:5371)
at sun.jdbc.odbc.JdbcOdbcResultSet.getInt(JdbcOdbcResultSet.java:722)
at sun.jdbc.odbc.JdbcOdbcResultSet.getInt(JdbcOdbcResultSet.java:740)
at AnalystImpl.getWork(AnalystImpl.java:236)
at PMGmanagerImpl.addWorkToUser(PMGmanagerImpl.java:415)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:324)
at sun.rmi.server.UnicastServerRef.dispatch(UnicastServerRef.java:261)
at sun.rmi.transport.Transport$1.run(Transport.java:148)
at java.security.AccessController.doPrivileged(Native Method)
at sun.rmi.transport.Transport.serviceCall(Transport.java:144)
at sun.rmi.transport.tcp.TCPTransport.handleMessages(TCPTransport.java:460)
at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run(TCPTransport.java:701)
at java.lang.Thread.run(Thread.java:536)


The resultset is valid and I can access other columnal data. Any thoughts please?

Rgds
Matt
 
This is a matter of the ODBC driver, so you must search the SQL server documentation to find out what happens. Try this:
Get the value as a String, to see what you get, and try to parse it with Double.parseDouble() or Long.parseLong so you can have the error catched in the java side, and find out what happens.

hope it helps.-
 
Is is possible that REFNUM is not the column name that the ODBC bridge needs? Try getting the columns in order by their number (ie: getInt(2)) and see if it works.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top