The JDBC statement is used to execute queries against the database. Statement is an interface which provides the methods to execute queries. We can get a statement object by invoking the createStatement() method of Connection interface.
Syntax: Statement stmt=conn.createStatement();
Commonly used methods of Statement interface:
1. execute(String SQL): It is used to execute SQL DDL statements.
Syntax: public boolean execute(String SQL)
2. executeQuery(String SQL): It is used to execute the select query and returns an object of ResultSet.
Syntax: public ResultSet executeQuery(String SQL)
3. executeUpdate(String SQL): It is used to execute the query like inset, update, delete etc. It returns the no. of affected rows.
Syntax: public int executeUpdate(String SQL)
4. executeBatch(): It is used to execute the batch of commands.
Syntax: public int[] executeBatch()
No comments:
Post a Comment