Granny's Programming Pearls
"inside of every large program is a small program struggling to get out"
JavaRanch.com/granny.jsp
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Jeanne Boyarsky
  • Devaka Cooray
  • Paul Clapham
Sheriffs:
  • Tim Cooke
  • Knute Snortum
  • Bear Bibeault
Saloon Keepers:
  • Ron McLeod
  • Tim Moores
  • Stephan van Hulst
  • Piet Souris
  • Ganesh Patekar
Bartenders:
  • Frits Walraven
  • Carey Brown
  • Tim Holloway

rs.first() error

 
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi. i am getting the following error when compiling:
cannot find method "first()"
-------
the code is this:
...
ResultSet rs = stmt.executeQuery("valid sql statement here");
if (rs.first()) {
...
and at the top of the file i have imported the java.sql package like so:
import java.sql.*;
------
so how come i can't call first() when it found the class ResultSet? and is there a better way to determine if anything was returned by the query?
thanks!
ed
 
ed copony
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
after more digging i see that my driver does not support the first() method -- i guess that explains it.
(i'll just be in here talking to myself if anyone needs me.)
 
Ranch Hand
Posts: 204
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hey ED
while creating the statement object do the following

and then execute the query
it will work
------------------
IBM Certified WebSphere Application Server V3.5 Specialist
 
author
Posts: 3252
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Won't work - he got a compile-time error, not a run-time error. Willing to bet that it's a JDBC 1 driver.
- Peter
 
Dharmesh Chheda
Ranch Hand
Posts: 204
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hey peter.. oops i didnt notice it .. thanx for correcting my reply..
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!