A)
//RepeatedDeletion.java
import java.util.Scanner;
import java.sql.*;
class RepeatedDeletion {
public static void main(String[] args) {
Connection con= DriverManager.getConnection("jdbc:odbc:prince","scott","tiger");
PreparedStatement ps=con.PreparedStatement("DELETE FROM ACCOUNT WHERE ACCNO=?");
Scanner s=new Scanner(System.in);
while(true)
{
System.out.println("Enter accno : ");
int ano=s.nextInt();
ps.setInt(1,ano);
intre=ps.executeUpdate();
if(re==0)
{
System.out.println("wrong accno");
}
else
System.out.println("deleted successfully");
System.out.println("one more account ? (yes/no)");
String choice=s.next();
if(choice.equals("no"))
break;
}
ps.close();
con.close();
}
}
Comments
Post a Comment