import java.sql.*;
import java.io.*;
class Slip23_2
{
static BufferedReader br =new BufferedReader(new InputStreamReader(System.in));
Connection con;
PreparedStatement ps;
Statement st;
ResultSet rs
void modify()throws Exception
{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
con=DriverManager.getConnection("jdbc:dbc:dsn");
System.out.print("Enter Roll no to be updated:");
int rno=Integer.parseInt(br.readLine());
System.out.print("Enter new Percentage :");
float per=Float.parseFloat(br.readLine());
String sql="update student set per=? where rno=?";
ps=con.prepareStatement(sql);
ps.setFloat(1,per);
ps.setInt(2,rno);
int n=ps.executeUpdate();
if(n>0)
System.out.println("Record Updated...");
}
void delete()throws Exception
{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
con=DriverManager.getConnection("jdbc:dbc:dsn");
System.out.println("Enter Roll No to be deleted :");
int rno=Integer.parseInt(br.readLine());
String sql="delete from student where rno=?";
ps=con.prepareStatement(sql);
ps.setInt(1,rno);
int n=ps.executeUpdate();
if(n>0)
System.out.println("Record Deleted...");
}
void viewAll()throws Exception
{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
con=DriverManager.getConnection("jdbc:dbc:dsn");
String sql="select * from student";
st=con.createStatement();
rs=st.executeQuery(sql);
System.out.println("Roll No\t Name \t Percentage");
while(rs.next
{
System.out.println(rs.getInt(1)+"\t"+rs.getString(2)+"\t"+rs.getFloat(3));
}
}
public static void main(String a[]) throws Exception
{
Slip23_2 ob = new Slip23_2();
NR CLASSES, PUNE (8796064387/90)
char ch;
do
{
String str = (a[0]);
ch=str.charAt(0);
switch(ch)
{
case 'U' : ob.modify();
break;
case 'D' : ob.delete();
break;
case 'R' : ob.viewAll();
break;
case 'E' : break;
}
}
while(ch!='E');
}
}