Statement Interface In JDBC

  • The Statement interface is used to execute the normal SQL statement to update or query the database.
  • A Statement interface object sends the required SQL statement as a query and then returns a set of results.
  • The Statement interface object is associated with Connection object.
  • The Statement object submits the SQL statement to database.
  • The database compiles the given SQL statement.
  • Then an execution plan is prepared by the database to execute the SQL statement.
  • The execution plan for the compiled SQL statement is then executed.
  • The executeXXX() method is called on Statement object with SQL statement.
  • The results are sent to the Statement object.
  • Finally the response is sent to the Java application in the form of ResultSet.

Let's see a program to insert a row using Statement interface:

import java.sql.*;
class JdbcInsertDemo
public static void main(String args[]) throws SQLException,ClassNotFoundException
Connection conn=DriverManager.getConnection("jdbc:oracle:thin:@localhost:1521:XE","system","password");
Statement st=conn.createStatement();
String s="insert into employee values(102,'Tapaswini',30000)";
int i=st.executeUpdate(s);
System.out.println(i+"row is inserted");

1 row is inserted

Our Services:

Java Training | Python Training | Machine Learning with Python Training | Deep Learning with Python Training | Data Science with Python Training | Projects

Silansoftware Pvt.Ltd, BBSR
Call to: 0674-2361252