>> Hi, excuse me, can anybody help?
>>
[quoted text clipped - 13 lines]
>
> or something like that...
thanks i tried , maybe it works or not, because when i use command String
name_variable =rs.getString(1) where rs is declared as record set. i wrote
prepareStatement(qry) where qry is "Select * from table where name_of_field
like ?" When I am testing rs is not empty, but still it seems getString
doesn't work (the types are not mixed for sure).
what's maybe the reason?
Thanks, Anna
John O'Conner - 23 Feb 2006 22:45 GMT
> thanks i tried , maybe it works or not, because when i use command String
> name_variable =rs.getString(1) where rs is declared as record set. i wrote
[quoted text clipped - 4 lines]
> what's maybe the reason?
> Thanks, Anna
The ResultSet "pointer" starts before the first returned record.
Typically one uses the following to iterate through the result set:
while(rs.next()) {
String name_variable = rs.getString(1);
// do something else
// ...
}
So, just try rs.next() to get to the first record.
--
John O'Conner
IchBin - 24 Feb 2006 02:40 GMT
>> thanks i tried , maybe it works or not, because when i use command
>> String name_variable =rs.getString(1) where rs is declared as record
[quoted text clipped - 15 lines]
>
> So, just try rs.next() to get to the first record.
Here is a link for "Using Prepared Statements" in Sun' tutorial :
http://java.sun.com/docs/books/tutorial/jdbc/basics/prepared.html
Also, here is a link to "The Java Developers Almanac 1.4" or code
samples for SQL Class:
http://javaalmanac.com/egs/java.sql/pkg.html
There is an example for "Inserting a Row into a Database Table Using a
Prepared Statement" did not look for one that does retrieve. There are
plenty of examples that show you how to loop thru a ResultSet.
Just remember the the order that you select the columns will be the
order they are returned in the ResultSet. Sounds like you are not doing
the correct order for calling rs.getString(1) or rs.getInt(i)...
BlabBlabBlab.
Thanks in Advance...
IchBin, Pocono Lake, Pa, USA
http://weconsultants.servebeer.com/JHackerAppManager
__________________________________________________________________________
'If there is one, Knowledge is the "Fountain of Youth"'
-William E. Taylor, Regular Guy (1952-)
Alexey Shevchenko - 27 Feb 2006 15:50 GMT
Ann, please do not use enumeration as "*". It's bad practice. Always use
only ovious values when you programming. Try to enumerate such columns you
have interested.
There is no waranty of order and count of the columns you have recieved in
your case.
What rs.getstring(1) should return if the first column is integer? Some time
it is work some time not
Good luck!
>>> Hi, excuse me, can anybody help?
>>>
[quoted text clipped - 22 lines]
> what's maybe the reason?
> Thanks, Anna