0% found this document useful (0 votes)
2 views4 pages

Exp 30

The document contains three Java programs that demonstrate basic SQL operations on a 'Student' table using JDBC. The first program updates a student's name, the second deletes a specific student, and the third deletes all records from the table. Each program handles exceptions and prints confirmation messages upon successful execution of the SQL commands.

Uploaded by

Amaan Chowlkar
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2 views4 pages

Exp 30

The document contains three Java programs that demonstrate basic SQL operations on a 'Student' table using JDBC. The first program updates a student's name, the second deletes a specific student, and the third deletes all records from the table. Each program handles exceptions and prints confirmation messages upon successful execution of the SQL commands.

Uploaded by

Amaan Chowlkar
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd

Experiment No.

30
Code:
import [Link].*;

public class Exp20


{
public static void main(String args[])
{
try
{
[Link]("[Link]");
Connection con=[Link]("jdbc:odbc:jdb1");
Statement st=[Link]();

[Link]("Before Updation - Student Table");


[Link]("Studid \t Studname ");
ResultSet rs=[Link]("Select * from Student");
while([Link]())
{
[Link]([Link](1)+"\t\t"+[Link](2));
}
[Link]("update Student set studname='Jack' where studname='Sami'");
[Link]("Record Updated");
[Link]();
}
catch(Exception e)
{
[Link]([Link]());
}
}
}
Code:
import [Link].*;
public class Exp20_1
{
public static void main(String args[])
{
try
{
[Link]("[Link]");
Connection con=[Link]("jdbc:odbc:jdb1");
Statement st=[Link]();
[Link]("delete from Student where studname='Jack'");
[Link]("Record Deleted");
[Link]();
}
catch(Exception e)
{
[Link]([Link]());
}
}
}
Code:
import [Link].*;
public class Exp20_2
{
public static void main(String args[])
{
try
{
[Link]("[Link]");
Connection con=[Link]("jdbc:odbc:jdb1");
Statement st=[Link]();
[Link]("delete * from student");
[Link]("All Records Deleted");
[Link]();
}
catch(Exception e)
{
[Link]([Link]());
}
}
}

You might also like