Tutorialspoint examples

Learn java tutorial with examples for beginners online

JDBC Statement interface


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()

JDBC Statement examples:

1. JDBC Statement creates a table example.

2. JDBC Statement inserts a record example.

3. JDBC Statement updates a record example.

4. JDBC Statement select records example.

5. JDBC Statement deletes a record example.

6. JDBC Statement batch update example.
 
Next Topic: JDBC Statement creates a table example.
Previous Topic: Connect to MySql database with JDBC driver.

Related Topics:

JDBC Statement creates a table example.
JDBC Statement inserts a record example.
JDBC Statement updates a record example.
JDBC Statement select records example.
JDBC Statement deletes a record example.
JDBC Statement batch update example.

 

Download tutorialspointexamples Android App
Copyright © 2018 Tutorialspoint examples DMCA.com Protection Status