0% found this document useful (0 votes)
338 views

AJP PR 19

This document demonstrates how to use a prepared statement and ResultSet interface to delete a record from a database table. It imports the necessary Java SQL classes, loads the JDBC driver, gets a connection to the "stud" database, creates a prepared statement to delete from the student table where the roll number equals a set integer (27), executes the delete, commits the transaction, and closes the connection. The output confirms the record was deleted successfully.

Uploaded by

Saraswati Shelke
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
338 views

AJP PR 19

This document demonstrates how to use a prepared statement and ResultSet interface to delete a record from a database table. It imports the necessary Java SQL classes, loads the JDBC driver, gets a connection to the "stud" database, creates a prepared statement to delete from the student table where the roll number equals a set integer (27), executes the delete, commits the transaction, and closes the connection. The output confirms the record was deleted successfully.

Uploaded by

Saraswati Shelke
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 1

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!

You might also like