anirudhp06

JDBCDemo2

Aug 17th, 2021
1,004
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.70 KB | None | 0 0
  1. import java.sql.*;
  2.  
  3. public class JDBCDemo2{
  4.     public static void main(String[] args) throws Exception{
  5.         Class.forName("oracle.jdbc.driver.OracleDriver");
  6.         Connection con=DriverManager.getConnection("jdbc:oracle:thin:@localhost:1521:XE","system","root");
  7.         Statement st=con.createStatement();
  8.         String s="update Student_Table2 set id='2' where name='Vineeth'";
  9.         st.executeUpdate(s);
  10.         String q1="delete from Student_Table2 where name='Vineeth'";
  11.         PreparedStatement ps=con.prepareStatement(q1);
  12.         ps.execute();
  13.         ResultSet rs=st.executeQuery("select * from Student_Table2");
  14.         while(rs.next()){
  15.             System.out.println(rs.getString(1)+" "+rs.getString(2));
  16.         }
  17.         rs.close();
  18.         con.close();
  19.     }
  20. }
Advertisement
Add Comment
Please, Sign In to add comment