top of page

How to execute SQL query in Java with JDBC connection

Let's see how we can execute query in the following code:


  1. public ResultSet executeQuery(String sql): is used to execute SELECT query. It returns the object of ResultSet.

  2. public int executeUpdate(String sql): is used to execute specified query, it may be create, drop, insert, update, delete etc.

  3. public boolean execute(String sql): is used to execute queries that may return multiple results.

  4. 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


Single post: Blog_Single_Post_Widget
bottom of page