*
The moose likes JDBC and the fly likes executeUpdate Error Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Databases » JDBC
Bookmark "executeUpdate Error" Watch "executeUpdate Error" New topic
Author

executeUpdate Error

Kassi Hill
Greenhorn

Joined: Sep 29, 2003
Posts: 24
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

Joined: Jun 28, 2001
Posts: 31
check your sql statement to make sure that the fields that you are using have the same types as your db table fields.


SCJP<br />SCWCD<br />SCEA Part I
Kassi Hill
Greenhorn

Joined: Sep 29, 2003
Posts: 24
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
internet detective
Marshal

Joined: May 26, 2003
Posts: 30123
    
150

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.


[Blog] [JavaRanch FAQ] [How To Ask Questions The Smart Way] [Book Promos]
Blogging on Certs: SCEA Part 1, Part 2 & 3, Core Spring 3, OCAJP, OCPJP beta, TOGAF part 1 and part 2
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: executeUpdate Error
 
Similar Threads
java.sql.SQLException: Server configuration denies access to data source
ORA-01000 maximum open cursors exceeded
Problems Inserting Info. into Access DB
Using prepared statements
HELP! Connection to MS Access DB Trouble