Importance of library management system.
A excellent library control machine allows librarians to without problems catalog books and preserve right facts of books issued, reissued, and people now not back. On the other hand, library customers can easily check the supply of any ebook that they want. A library management device reduces the cost of management.
To get help you can see the video.
Source code for add new book page.
- Connect with connection class…
Connection con = null;
ResultSet rs;
PreparedStatement pst;
public New_Book() {
initComponents();
con = Connect.dbConnect();
middle();
}
public void middle(){
setLocationRelativeTo(null);
}
2. Add new book codeā¦
try{
if(jTextField1.getText().equals("") || jTextField2.getText().equals("") || jTextField3.getText().equals("") || jTextField4.getText().equals("") || jTextField5.getText().equals("")){
JOptionPane.showMessageDialog(null, "Field Must Not Empty !!!");
}else{
String sql = "select Book_ID from book where Book_ID = ?";
pst = con.prepareStatement(sql);
pst.setString(1, jTextField1.getText());
rs = pst.executeQuery();
if(rs.next()){
JOptionPane.showMessageDialog(null, jTextField1.getText()+" This Book ID Already Exists...!!!");
}else{
String sql1 = "insert into book(Book_ID,Name,Edition,Publisher,Price,Pages) values(?,?,?,?,?,?)";
pst = con.prepareStatement(sql1);
pst.setString(1, jTextField1.getText());
pst.setString(2, jTextField2.getText());
pst.setString(3, (String) jComboBox1.getSelectedItem());
pst.setString(4, jTextField3.getText());
pst.setString(5, jTextField4.getText());
pst.setString(6, jTextField5.getText());
pst.execute();
JOptionPane.showMessageDialog(null, "Successfully Insertde...!!!");
}
}
}catch(HeadlessException | SQLException e){
JOptionPane.showMessageDialog(null, e);
}
Be First to Comment