Ajp Practical 20
Ajp Practical 20
Ajp Practical 20
: 20
Import java.sql.*;
public class Emp
{
public static void main(String[] args){
try{
Connection con = DriverManager.getConnection("jdbc:ucanaccess://D://Employee1.accdb");
Statement s = con.createStatement();
s.execute("Create Table SData (STUD_ID int, STUD_Name varchar(255),BRANCH
varchar(255))");
s.execute("Delete from SData where STUD_ID=101");
s.execute("select * from SData");
ResultSet rs = s.getResultSet();
if (rs != null){
while ( rs.next() ) {
System.out.println("Id of the Student: " + rs.getString(1) );
System.out.println("Name of Student: " + rs.getString(2) );
System.out.println("Branch of Student: " + rs.getString(3) );
System.out.println("********************************************88" );}
s.close();
con.close();}}
catch (Exception err){
System.out.println("ERROR: " +err);
}
}
}
Output
XIII. Exercise
import java.sql.*;
public class Emp
{
public static void main(String[] args){
try{
Connection con =
DriverManager.getConnection("jdbc:ucanaccess://D://Employee1.accdb");
Statement s = con.createStatement();
// s.execute("Create Table SData (STUD_ID int, STUD_Name
varchar(255),BRANCH varchar(255))");
s.execute("Update SData set STUD_NAME = 'john' where STUD_NAME = 'Jack')");
s.execute("select * from SData");
ResultSet rs = s.getResultSet();
if (rs != null){
while ( rs.next() ) {
System.out.println("Id of the Student: " + rs.getString(1) );
System.out.println("Name of Student: " + rs.getString(2) );
System.out.println("Branch of Student: " + rs.getString(3) );
System.out.println("********************************************88"
);}
s.close();
con.close();}}
catch (Exception err){
System.out.println("ERROR: " +err);
}
}
}
2.Develop a program to delete all record for a product whose “price” id” is greater
than 500 and Id is “P1234”
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.Statement;
Output