Java2all.com  

Statement Interface





Share This Topic -

Statement Interface:

The Statement interface is used for to execute a static query.

It’s a very simple and easy so it also calls a “Simple Statement”.

The statement interface has several methods for execute the SQL statements and also get the appropriate result as per the query sent to the database.

Some of the most common methods are as given below

Method

Description

void close()

This method frees an object of type Statement from database and other JDBC resources.

boolean execute(String s)

This method executes the SQL statement specified by s. The getResultSet() method is used to retrieve the result.

ResultSet getResultet()

This method retrieves the ResultSet that is generated by the execute() method.

ResultSet executeQuery(String s)

This method is used to execute the SQL statement specified by s and returns the object of type ResultSet.

int getMaxRows()

This method returns the maximum number of rows those are generated by the executeQuery() method.

Int executeUpdate(String s)

This method executes the SQL statement specified by s. The SQL statement may be a SQL insert, update and delete statement.

The example program for Statement interface and its methods are given in next chapter for different databases.