aspose file tools*
The moose likes JDBC and the fly likes ResultSet issue with adding record Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Databases » JDBC
Bookmark "ResultSet issue with adding record" Watch "ResultSet issue with adding record" New topic
Author

ResultSet issue with adding record

Joseph Smithern
Ranch Hand

Joined: Feb 11, 2006
Posts: 89
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

Joined: Sep 24, 2006
Posts: 2
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

Joined: Sep 24, 2006
Posts: 2
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

Joined: Feb 11, 2006
Posts: 89
Thanks,

I appreciate your answer and now I learned that executeUpdate method always returns an int data type.
Rajesh Agarwal
Ranch Hand

Joined: Aug 01, 2005
Posts: 79
Also remember the following

boolean execute(String)
int executeUpdate(String)
ResultSet executeQuery(String)
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: ResultSet issue with adding record