Nov
17
import java.sql.*;
import java.io.*;
class TestDb8{
public static void main(String ard[]){
try{
Class.forName(“sun.jdbc.odbc.JdbcOdbcDriver”);
Connection con=DriverManager.getConnection(“jdbc:odbc:BCADSN”,”system”,”ram”);
System.out.println(“Con established”);
Statement stmt=con.createStatement();
System.out.println(“statement created”);
//——————— TO DELETE RECORED——–
Console c=System.console();
String empno=c.readLine(“Enter Emp No want to delete: “);
String qu=”delete from emp where empno=”+empno;
System.out.println(qu);
int num=stmt.executeUpdate(qu);
if(num==0){
System.out.println(“No such record found”);
}
// ———————— END —————————-
qu=”select * from emp order by empno”;
ResultSet rs=stmt.executeQuery(qu);
while(rs.next()){
System.out.println(rs.getString(“empno”)+”\t”+rs.getString(“ename”).toUpperCase()+”\t”+rs.getString(“mobile”));
}
rs.close();
stmt.close();
con.close();
}catch(Exception e){
System.out.println(e);
}
}
}