|
|
Can't get column data by index from JDBC executequery
Newbie question ... posted also to Stackoverflow
http://stackoverflow.com/questions/3129112/why-cant-i-access-column-data-by-integer-from-executequery-obj
but there is no NetRexx tag there :(
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://rebol.wik.is/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?
|
|
0
|
|
|
|
Reply
|
Graham
|
6/27/2010 11:24:47 PM |
|
On Jun 28, 11:24=A0am, Graham <compkar...@gmail.com> wrote:
> Newbie question ... posted also to Stackoverflowhttp://stackoverflow.com/=
questions/3129112/why-cant-i-access-column-d...
> but there is no NetRexx tag there :(
>
> 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 herehttp://rebol.wik.is/NetRexx/JDBC-bridge.nrx
>
> When I try to loop thru the column data
>
> =A0 =A0 loop col=3D1 to nbr_columns
> =A0 =A0 =A0say 'Column' col
> =A0 =A0 =A0-- say rs.getString(col) -- gives error Message: =A0Column nam=
e 1
> not found in result set.
> =A0 =A0 =A0if buffer =3D '' then
> =A0 =A0 =A0 =A0 =A0buffer =3D rs.getString(column_name).trim()
> =A0 =A0 =A0else
> =A0 =A0 =A0 =A0 =A0buffer =3D buffer || '|' || rs.getString(column_name).=
trim()
> =A0 =A0 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. =A0But if I do this:
>
> =A0 =A0 say rs.getString(1)
>
> it's fine. =A0Is this because col is a Rexx string and not a Java
> integer or something?
>
trial and error got this working, rs.getString(int col)
> Also, I have to close the socket and thread after each query otherwise
> I don't get any response back. =A0 Is this necessary or can I somehow
> leave the thread running to accept new queries?
|
|
0
|
|
|
|
Reply
|
Graham
|
6/28/2010 4:22:33 AM
|
|
On Jun 28, 4:22=A0pm, Graham <compkar...@gmail.com> wrote:
>
> trial and error got this working, rs.getString(int col)
>
>
>
> > Also, I have to close the socket and thread after each query otherwise
> > I don't get any response back. =A0 Is this necessary or can I somehow
> > leave the thread running to accept new queries?
Actually I wonder if this is a NetRexx bug. The docs say that types
are converted automatically but the integer is being converted to a
Java string.
|
|
0
|
|
|
|
Reply
|
Graham
|
6/29/2010 7:44:22 AM
|
|
On 29.06.2010 09:44, Graham wrote:
> On Jun 28, 4:22 pm, Graham <compkar...@gmail.com> wrote:
>>
>> trial and error got this working, rs.getString(int col)
>>
>>
>>
>>> 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?
>
> Actually I wonder if this is a NetRexx bug. The docs say that types
> are converted automatically but the integer is being converted to a
> Java string.
Probably not. AFAIK the method you are using is overloaded, one having a String argument, the other
an int one, so any choice of automatic conversion would find an existing method and hence be correct
by definition.
You may want to research the heuristics of NetRexx when applying "automatic conversion". Only if
your observation does not match the NetRexx definition could that be regarded as an error.
---rony
|
|
0
|
|
|
|
Reply
|
rony
|
6/29/2010 9:58:52 AM
|
|
|
3 Replies
143 Views
(page loaded in 0.091 seconds)
|
|
|
|
|
|
|
|
|