import [Link].
*;
import [Link].*;
public class Prog7 {
public static void main(String[] args)throws Exception
{
while(true)
{
[Link]("\n [Link] a Record\n
[Link] Record \n
[Link] a Record \n
4 Search Record \n
5 Exit");
[Link]("Enter your choice : ");
DataInputStream br=new DataInputStream([Link]);
int x=[Link]([Link]());
switch(x)
{
case 1:
[Link]("[Link]");
Connection conn=[Link]
("jdbc:mysql://localhost:3306/abc","root","");
[Link]("Inserting Records...");
PreparedStatement ps=[Link]("insert into books
values(?,?,?,?)");
[Link]("Enter Book ID --->");
int bid=[Link]([Link]());
[Link]("Enter title of book --->");
String title=[Link]();
[Link]("Enter Author Name --->");
String auth=[Link]();
[Link]("Enter price --->");
float pr=[Link]([Link]()).floatValue();
[Link](1,bid);
[Link](2,title);
[Link](3,auth);
[Link](4,pr);
[Link]();
[Link]("Record Inserted");
[Link]();
break;
case 2:
[Link]("[Link]");
Connection con=[Link]
("jdbc:mysql://localhost:3306/abc","root","");
[Link]("Enter Book ID of record you wish to update :");
bid=[Link]([Link]());
[Link] (Enter New Title :);
title=[Link]([Link]());
String str=update book set title=? Where Book_id=?;
PreparedStatement ps=[Link](str);
[Link](1,title);
[Link](2,bid);
[Link]();
[Link]("Record Updated");
break;
case 3:
[Link]("[Link]");
Connection con=[Link]
("jdbc:mysql://localhost:3306/abc","root","");
[Link]("Enter Book ID of record you want to delete :");
bid=[Link]([Link]());
String sql=delete from book where Book_id=?;
PreparedStatement ps=[Link](sql);
[Link](1,bid);
[Link]();
[Link]("Record Deleted");
break;
case 4:
[Link]("[Link]");
Connection con=[Link]
("jdbc:mysql://localhost:3306/abc","root","");
[Link]("Enter Book ID to search :");
String t1=[Link]();
Statement st=[Link]();
String str="select * from books where Book_id="+t1;
ResultSet rs=[Link](str);
while([Link]())
{
[Link]([Link](1)+" "+[Link](2)+" "+[Link](3)+"
"+[Link](4));
}
break;
case 5:
[Link](0);
break;
}
}
}
}