package sql; import java.sql.Connection; import java.sql.DriverManager; import java.sql.PreparedStatement; import java.sql.ResultSet; import java.sql.SQLException; public class ConnectionDemo { public static void main(String[] args) { try { Class.forName("oracle.jdbc.driver.OracleDriver"); Connection con = DriverManager.getConnection("jdbc:oracle:thin:@localhost:1521:XE","system","9848451415"); PreparedStatement st = con.prepareStatement("insert into emp(empno,ename) values(?,?)"); st.setInt(1, 3); st.setString(2, "Naresh"); if(st.execute()){ System.out.println("Successfull executed"); } else System.out.println("Failed"); } catch (ClassNotFoundException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (SQLException e) { // TODO Auto-generated catch block e.printStackTrace(); } } }
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)