Skip to main content

Posts

Showing posts with the label Delete

JDBC application For Delete Operation

 JDBC application For Delete Operation Create Table:: SQL> create table test1(eid int,ename varchar2(10)); Table created. SQL> insert into test1 values(1,'vijay'); 1 row created. SQL> insert into test1 values(2,'rajesh'); 1 row created. SQL> select * from test1;        EID ENAME ---------- ----------          1 vijay          2 rajesh SQL> commit; Commit complete. JDBC application::: import java.sql.*; class Test { public static void main(String[] args)throws Exception{ //load JDBC driver //get connection Connection con = DriverManager.getConnection("jdbc:oracle:thin:@localhost:1521:orcl","system","tiger"); //create statement obj Statement st = con.createStatement(); //prepare and execute query String query = "delete from test1 where eid=2"; int count = st.executeUpdate(query); if(count==0){ System.out.println("No Row is deleted"); }else{ System.out.println(count+&qu