How to execute SQL query in Java with JDBC connection
Let's see how we can execute query in the following code:
public ResultSet executeQuery(String sql): is used to execute SELECT query. It returns the object of ResultSet.
public int executeUpdate(String sql): is used to execute specified query, it may be create, drop, insert, update, delete etc.
public boolean execute(String sql): is used to execute queries that may return multiple results.
public int[] executeBatch(): is used to execute batch of commands.
In ResultSet object, it include a cursor pointing to a row of a table.
Comments