Ad Code

EXECUTE QUERY SQL AND UPDATE QUERY SQL


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);
Reactions

Post a Comment

0 Comments