WRITE A DIFFERENCE BETWEEN EXECUTE QUERY SQL AND UPDATE QUERY SQL METHOD?
executeQuery(sql) method
Used for SQL SELECT queries
Returns the ResultSET object that contains the results of the query and can be used to access the query results.
String sql = “SELECT * from sometable”;ResultSet rs =stmt.executeQuery(sql); executeUpdate(sql)method
This method is used for executing an update statement like INSERT, UPDATE or DELETE
Returns an integer value representing the number of rows updated
String sql = “INSERT INTO tablename ” + “(columnNames) Values (values)” ; int count = stmt.executeUpdate(sql);
Used for SQL SELECT queries
Returns the ResultSET object that contains the results of the query and can be used to access the query results.
String sql = “SELECT * from sometable”;ResultSet rs =stmt.executeQuery(sql); executeUpdate(sql)method
This method is used for executing an update statement like INSERT, UPDATE or DELETE
Returns an integer value representing the number of rows updated
String sql = “INSERT INTO tablename ” + “(columnNames) Values (values)” ; int count = stmt.executeUpdate(sql);
EXECUTE QUERY SQL AND UPDATE QUERY SQL
Reviewed by MCH
on
April 27, 2014
Rating:
No comments: