• 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
  • Bear Bibeault
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
Sheriffs:
  • Tim Cooke
  • Liutauras Vilda
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • fred rosenberger
  • salvin francis
Bartenders:
  • Piet Souris
  • Frits Walraven
  • Carey Brown

ResultSet issue with adding record

 
Ranch Hand
Posts: 89
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am trying to compile the below JDBC class file but it gives me error message about the ResultSet class:


Here is my java file that has a method (addRecord) that will be called by a Servlet:

[ September 24, 2006: Message edited by: Joseph Smithern ]
 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I think what you want to use is executeUpdate - which is used for INSERTS, etc, and returns a int showing the row count

See here
[ September 24, 2006: Message edited by: Ian Singe ]
 
Ian Singe
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Also, it's better practise to use prepared statement, rather than just statement, as it's 'safer' (not to mention easier) - you use it like so :

 
Joseph Smithern
Ranch Hand
Posts: 89
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks,

I appreciate your answer and now I learned that executeUpdate method always returns an int data type.
 
Ranch Hand
Posts: 79
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Also remember the following

boolean execute(String)
int executeUpdate(String)
ResultSet executeQuery(String)
    Bookmark Topic Watch Topic
  • New Topic