Why can't I access column data by integer from executeQuery obj?

260 views Asked by At

I'm a two day newbie in both NetRexx and Java.

I tried to modify the IBM red book examples to create a multi-threaded tcp server that executes SQL on a firebird database.

The first attempt is here http://www.compkarori.co.nz:8000/NetRexx/JDBC-bridge.nrx

When I try to loop thru the column data

loop col=1 to nbr_columns 
 say 'Column' col
 -- say rs.getString(col) -- gives error Message:  Column name 1 not found in result set.
 if buffer = '' then 
     buffer = rs.getString(column_name).trim()
 else
     buffer = buffer || '|' || rs.getString(column_name).trim()
end

I get an error as in the code comments if I use the loop counter as the index viz: rs.getString(col) and so I am resorting to using the columnname. But if I do this:

say rs.getString(1)

it's fine. Is this because col is a Rexx string and not a Java integer or something?

Also, I have to close the socket and thread after each query otherwise I don't get any response back. Is this necessary or can I somehow leave the thread running to accept new queries?

( ps: can someone add a NetRexx tag?? )

1

There are 1 answers

0
Graham Chiu On BEST ANSWER

The getString method is overloaded which is why I need to force the int value. And I figured out on how to reuse the thread and socket .. noting that only the Oracle and Firebird/Interbase JDBC connection objects appear to be thread safe