JDBC

JDBC Projects

JDBC Project 1

JDBC Using Statement example Delete record using id
Previous Home Next
/* This program shows you how to delete a record
from the database table using JDBC Statement.
In this example ,you give the id,that you want
to delete.*/

package r4r;
import java.sql.*;
import java.util.*;
public class DeleteData
{
public static void main(String[] args) {
try
{
Scanner s=new Scanner(System.in);
System.out.println("Enter id:-");
int s1=s.nextInt();
s.nextLine();
Class.forName("oracle.jdbc.driver.OracleDriver");
Connection con=DriverManager.getConnection
("jdbc:oracle:thin:@localhost:1521:xe","system","oracle");
Statement stmt=con.createStatement();
stmt.executeQuery("delete from user5 where id='"+s1+"'");
System.out.println("successfully deleted");
con.close();
}
catch(Exception e)
{
System.out.println(e);
}
}
}

 

output:

Enter id:-
7
successfully deleted
Previous Home Next

Tolal:0 Click:

Show All Comments

Did not find what you were looking for leave your name and message. We will revert within 24 hours
Name:
eMail:
Comment / Feedback: