Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

ResultSet issue with adding record

 
Joseph Smithern
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 ]
 
Ian Singe
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.
 
Rajesh Agarwal
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)
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic