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

executeUpdate Error

 
Kassi Hill
Greenhorn
Posts: 24
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am trying to run an SQL update statement and I am passing the SQL as a string into a method. I am getting the following error message:
"DataAccess.java": Error #: 354 : incompatible types; found: int, required: java.sql.ResultSet at line 58, column 30"
I do not under stand the message, Your help would be greatly appreciated!!
This is the code:
public void runUpdateQuery(String sql){
//This method is called from the Business DataAccess Classes each time an
//Update needs to be made to the DataBase such as Insert, Delete statements
try{
conCounter ++;
openConnection();//Open the Connection
stmt = conn.createStatement();//Create Statement Object
rs = stmt.executeUpdate(sql
closeConnection();//Close Connection
}catch(SQLException sqle) {
System.err.println("SQL NOT Executed: " + sqle);
}//end try/catch
}//end runUpdateQuery
 
Bill Wang
Ranch Hand
Posts: 31
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
check your sql statement to make sure that the fields that you are using have the same types as your db table fields.
 
Kassi Hill
Greenhorn
Posts: 24
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am getting this error when I try compiling the program. I have not yet been able to send an actual statement yet because I have not been able to successfully compile the program.
 
Jeanne Boyarsky
author & internet detective
Marshal
Posts: 34671
367
Eclipse IDE Java VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
executeUpdate() should return an int - the number of rows successfully updated. It is used for insert, update and delete statements. executeQuery() is the one that returns a result set. It is used for select statements.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic