//Deleting values in table student
import java.sql.*;
public class Delete_Records
{
public static void main(String args[])
{
try
{
DriverManager.registerDriver(new oracle.jdbc.driver.OracleDriver());
System.out.println("thin driver is registerd");
Connection con=DriverManager.getConnection("jdbc:oracle:thin:@localhost:1521:xe","system","system");
System.out.println("Connection is established to DB");
Statement stmt=con.createStatement();
System.out.println("Statement object is created");
int a=stmt.executeUpdate("delete from student where sno=1");
System.out.println("Values are deleted -------> "+a);
}
catch(Exception e)
{
e.printStackTrace();
System.out.println("Registeration faild");
}
}
}
/*
Explanation:
Here we use a SQL update Query
and it returns an interger value it indicates that how many record are deleted.
*/
No comments:
Post a Comment