Practical no: 19
Title: WAP to demonstrate the use of Prepared statement and Reseltset interface.
//update using prepared statement a record
importjava.sql.*;
public class Delete10
{
public static void main(String ar[])throws Exception
{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
System.out.println("Drivers loaded");
Connection c1=DriverManager.getConnection("Jdbc:Odbc:stud");
System.out.println(" connection statement obj created");
PreparedStatementps=c1.prepareStatement("delete from student where roll=?");
System.out.println(" prepared statement obj created");
ps.setInt(1,27);
ps.executeUpdate();
System.out.println("Record Deleted!");
c1.commit();
c1.close();
}
}
-----------------------------------------------output---------------------------------------------------------
connection statement obj created
prepared statement obj created
Record Deleted!