Professional Documents
Culture Documents
11 MINI-PROJECT
AIM
DESIGN PLAN
Project Plan
Software requirement Analysis
Implementation and Coding
Software testing
Software Debugging
Conclusion
DESCRIPTION
We are very delighted and excited to finish this mini-project, as this is our first project involving
Databases. We have used MySql as Back-end and Java for Front-end work. We have used an
additional extension file named “rs2xml”. This project is for maintaining records of the books issued
by the librarian to the person. We have also added some features like Update and Delete, in case of
mistakes, while entering the details.
SOFTWARE REQUIREMENTS
MySql Database
Eclipse IDE
Mysql connector jar file
TABLES
1) BOOK
create table book(id int(11) auto_increment , name varchar(255),edition int(15),price
int(15),primary key(id));
3) Import the packages: Requires that you include the packages containing the JDBC classes
needed for database programming. Most often using import java.sql.* will suffice.
4) Register the JDBC driver:- Requires that you initialize a driver so you can open a
6) Execute a Query: Requires using an object of type statement for building and submitting
an SQl
7) Extract data from ResultSet: Requires that you use the appropriate ResultSet.getXXX()
method to retrieve the data from the ResultSet
import java.awt.EventQueue;
import java.sql.*;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JOptionPane;
import java.awt.Font;
import javax.swing.JPanel;
import javax.swing.border.TitledBorder;
import javax.swing.JoptionPane;
import net.proteanit.sql.DbUtils;
import javax.swing.JTextField;
import javax.swing.JButton;
import javax.swing.JTable;
import javax.swing.JScrollPane;
import java.awt.event.ActionListener;
import java.awt.event.ActionEvent;
import java.awt.event.KeyAdapter;
import java.awt.event.KeyEvent;
/**
* Launch the application.
*/
public static void main(String[] args) {
EventQueue.invokeLater(new Runnable() {
public void run() {
try {
JavaCrud window = new JavaCrud();
window.frame.setVisible(true);
} catch (Exception e) {
e.printStackTrace();
}
}
});
}
/**
* Create the application.
*/
public JavaCrud() {
initialize();
Connect();
table_load();
}
Connection con;
PreparedStatement pst;
ResultSet rs;
/**
* Initialize the contents of the frame.
*/
private void initialize() {
frame = new JFrame();
frame.setBounds(100, 100, 1118, 594);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.getContentPane().setLayout(null);
try {
pst = con.prepareStatement("insert into
book(name,edition,price)values(?,?,?);");
pst.setString(1, bname);
pst.setString(2, edition);
pst.setString(3, price);
pst.executeUpdate();
JOptionPane.showMessageDialog(null,
"Record Added Successfully!!");
table_load();
txtbname.setText("");
txtedition.setText("");
txtprice.setText("");
txtbname.requestFocus();
}
}
});
btnNewButton.setBounds(25, 363, 89, 35);
frame.getContentPane().add(btnNewButton);
}
});
btnClear.setBounds(271, 363, 89, 35);
frame.getContentPane().add(btnClear);
String id = txtbid.getText();
pst = con.prepareStatement("select
name,edition,price from book where id = ?");
pst.setString(1, id);
ResultSet rs = pst.executeQuery();
if(rs.next()==true)
{
txtbname.setText(name);
txtedition.setText(edition);
txtprice.setText(price);
}
else
{
txtbname.setText("");
txtedition.setText("");
txtprice.setText("");
}
}
});
txtbid.setColumns(10);
txtbid.setBounds(122, 34, 226, 20);
panel_1.add(txtbid);
try {
pst = con.prepareStatement("update book set name
= ?,edition=?,price=? where id =?");
pst.setString(1, bname);
pst.setString(2, edition);
pst.setString(3, price);
pst.setString(4, bid);
pst.executeUpdate();
JOptionPane.showMessageDialog(null, "Record
Updated Successfully !!");
table_load();
txtbname.setText("");
txtedition.setText("");
txtprice.setText("");
txtbname.requestFocus();
}
e1.printStackTrace();
}
}
});
btnUpdate.setBounds(638, 431, 89, 35);
frame.getContentPane().add(btnUpdate);
bid = txtbid.getText();
try {
pst = con.prepareStatement("delete from book
where id = ?");
pst.setString(1, bid);
pst.executeUpdate();
JOptionPane.showMessageDialog(null, "Record
Deleted Sucessfully !!");
table_load();
txtbname.setText("");
txtedition.setText("");
txtprice.setText("");
txtbname.requestFocus();
}
e1.printStackTrace();
}
}
});
btnDelete.setBounds(808, 431, 89, 35);
frame.getContentPane().add(btnDelete);
}
}
INSERT
UPDATE
DELETE
RESULT:
Thus the front end and back end for the Book Record Management was designed and
executed successfully