Skip to main content

Posts

Showing posts with the label Insert

JDBC Application For Insert Operation

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