This is the mail archive of the
kawa@sources.redhat.com
mailing list for the Kawa project.
java.sql.ResultSet.getObject() Kawa(?) bug
- From: "Hoehle, Joerg-Cyril" <Joerg-Cyril dot Hoehle at t-systems dot com>
- To: kawa at sources dot redhat dot com, brl-users at lists dot sourceforge dot net
- Date: Mon, 29 Jul 2002 16:12:25 +0200
- Subject: java.sql.ResultSet.getObject() Kawa(?) bug
Hi,
I took some time to track down the failure to use "SELECT * FROM ..." with ODBC in BRL.
Kawa/BRL break on the code below, while both jscheme and Jython work, using the same JVM.
*Maybe* what's confusing Kawa is that rs.getObject/getInt/getString are polymorphic. They accept either a Java int (index) or string (column name).
MY testharness (you'll have to define an ODBC source):
(require <sun.jdbc.odbc.JdbcOdbcDriver>)
(set! con (invoke-static <java.sql.DriverManager> 'getConnection "jdbc:odbc:Abkuerzungen"))
(set! st (invoke con 'createStatement))
(set! rs (invoke st 'executeQuery "SELECT * FROM Abkuerzungen"))
(invoke rs 'next)
Now I'm trying to use
#|kawa:42|# (invoke rs 'getObject 1)
and I get one of the following 2 errors.
The first comes from Kawa. The presence of 2 spaces between "Argument" and "to" is weird. It looks like it's not even trying to call the driver.
The second comes from the driver. The findColumn() in the backtrace seems to indicate that it did not take 1 as an index, treats it as a string instead and attempts to find the index of the column of that name. Maybe some <gnu.math.IntNum> vs. <java.lang.Integer> problem?
#|kawa:200|# (invoke rs 'getObject 1)
Argument to 'sun.jdbc.odbc.JdbcOdbcResultSet.getInt' has wrong type
at gnu.expr.GenericProc.applyN(GenericProc.java:74)
at gnu.kawa.reflect.Invoke.applyN(Invoke.java:149)
at gnu.kawa.reflect.Invoke.applyN(Invoke.java:49)
at gnu.mapping.Procedure.apply(Procedure.java:102)
at gnu.mapping.CallContext.runUntilDone(CallContext.java:235)
at gnu.expr.ModuleExp.evalModule(ModuleExp.java:189)
at kawa.Shell.run(Shell.java:229)
at kawa.Shell.run(Shell.java:180)
at kawa.Shell.run(Shell.java:167)
at kawa.repl.processArgs(repl.java:275)
at kawa.repl.main(repl.java:528)
or:
#|kawa:42|# (invoke rs 'getObject 1)
java.sql.SQLException: Column not found -- why is backtrace different now??
at sun.jdbc.odbc.JdbcOdbcResultSet.findColumn(Unknown Source)
at sun.jdbc.odbc.JdbcOdbcResultSet.getObject(Unknown Source)
at java.lang.reflect.Method.invoke(Native Method)
at gnu.expr.PrimProcedure.applyV(PrimProcedure.java:142)
at gnu.expr.GenericProc.applyN(GenericProc.java:61)
at gnu.kawa.reflect.Invoke.applyN(Invoke.java:149)
at gnu.kawa.reflect.Invoke.applyN(Invoke.java:49)
at gnu.mapping.Procedure.apply(Procedure.java:102)
at gnu.mapping.CallContext.runUntilDone(CallContext.java:239)
at gnu.expr.ModuleExp.evalModule(ModuleExp.java:189)
at kawa.Shell.run(Shell.java:231)
at kawa.Shell.run(Shell.java:180)
at kawa.Shell.run(Shell.java:167)
at kawa.Shell.run(Shell.java:154)
at kawa.repl.main(repl.java:561)
(invoke rs 'getInt "AbkId") works (i.e. getInt/Object/String/Long by column name).
Equivalent code in jscheme or jython works:
(java.lang.Class.forName "sun.jdbc.odbc.JdbcOdbcDriver")
(set! con (java.sql.DriverManager.getConnection "jdbc:odbc:Abkuerzungen"))
(set! st (.createStatement con))
(set! rs (.executeQuery st "SELECT * FROM Abkuerzungen"))
(.next rs)
(.getObject rs 1)
(.getObject rs "AbkId")
(.getObject rs 2)
(.getObject rs "Name")
(.getObject rs "Bedeutung")
import sun.jdbc.odbc.JdbcOdbcDriver
import java.sql
con=java.sql.DriverManager.getConnection("jdbc:odbc:Abkuerzungen")
dir(java.sql.Connection)
st = con.createStatement()
rs = st.executeQuery("SELECT * FROM Abkuerzungen")
rs.next()
rs.getLong(1) -> 1L
rs.getObject(2)
Regards,
Jörg Höhle.
[I scanned http://jtds.sourceforge.net/ for documentation on the available java.sql.ResultSet/Connection methods.]
Tests with kawa-1.6.98 or brl-2.3.0+kawa-1.6.97.1brl
JDK/JRE-1.3.1 (which includes the JDBC-ODBC bridge) on MS-Woes2k.