Statement interface

The Statement interface gives techniques to execute questions with the database. The announcement interface is an industrial facility of ResultSet i.e. it gives plant strategy to get the object of ResultSet.


Normally utilized systems for Statement interface:

The vital systems for Statement interface are as per the following:

  • public ResultSet executeQuery(String sql); is utilized to execute SELECT question. It gives back the object of ResultSet.
  • public int executeUpdate(String sql); is utilized to execute indicated question, it might be make, drop, supplement, redesign, erase and so on.
  • public boolean execute(String sql); is utilized to execute questions that may give back numerous outcomes.
  • public int[] executeBatch(); is utilized to execute cluster of charges. Sample of Statement interface How about we see the basic sample of Statement interface to embed, overhaul and erase the record.

Example of Statement interface

 import java.sql.*;

class FetchRecord {
	public static void main(String args[])throws Exception{ 


class.forName("oracle.jdbc.driver.OracleDriver"); 
Connection con=DriverManager.getConnection("jdbc:oracle:thin:@localhost:1521:xe","system","oracle"); 
Statement stmt=con.createStatement(); 
//stmt.executeUpdate("insert into emp765 values(33,'Mithilesh',50000)"); 
//int result=stmt.executeUpdate("update emp765 set name='Vimal',salary=10000 where id=33"); 
int result=stmt.executeUpdate("delete from emp765 where id=33"); 
 
System.out.println(result+" records influenced"); 
con.close(); 

}}