Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                

AJP 20

Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 4

EXP.

20

1. WAP to delete a record from a table.

2. Write the output of the following.


3. WAP to update name of a student from Jack to John.
import jdk.jfr.RecordingState;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.Statement;

public class EXpt20_1 {

public static void main(String[] args) {


try
{
System.out.println("Driver loaded");
Connection con =
DriverManager.getConnection("jdbc:ucanaccess://C:\\Users\\Admin\\.jdks\\
corretto-1.8.0_432\\bin\\DB18.accdb");
System.out.println("Connection established");
Statement s = con.createStatement();
s.executeUpdate("Update Student1 set NAME='JOHN' where
NAME='JACK' ");
System.out.println("Table is created");
Statement stmt2 = con.createStatement();
ResultSet rs = stmt2.executeQuery("select * from Student1 ");
while(rs.next())
{
System.out.println("NAME: " + rs.getString("NAME"));
System.out.println("ROLL: " + rs.getInt("ROLLNO"));
System.out.println("Percentage: " +
rs.getInt("PERCENTAGE"));
}

con.close();
} catch (Exception e) {
System.out.println(e);
}
}
}
4. WAP to delete all records for a product whose “price is grater then 500”
and Id is”P1234”.

You might also like