0% found this document useful (0 votes)
49 views16 pages

Book Publication System

This document describes a book publication system that allows users to save, update, and delete records for authors, editors, books, and outlets in a MySQL database. It includes Java code for connecting to the database and executing SQL statements to perform CRUD operations on various tables for each entity.
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
49 views16 pages

Book Publication System

This document describes a book publication system that allows users to save, update, and delete records for authors, editors, books, and outlets in a MySQL database. It includes Java code for connecting to the database and executing SQL statements to perform CRUD operations on various tables for each entity.
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 16

Book Publication System

JSAD 64 BATCH A.G.T.B.B. ABEYKOON 910093207V

BOOK PUBLICATION SYSTEM Author Details

Save Button Code


private void btnSaveActionPerformed(java.awt.event.ActionEvent evt) { try { String gender=""; Class.forName("com.mysql.jdbc.Driver"); Connection c = DriverManager.getConnection("jdbc:mysql://localhost:3306/bookpublication","root",""); Statement s = c.createStatement(); if (rdbMale.isSelected()) { gender = "Male"; } else if (rdbFemale.isSelected()) { gender = "Female"; } s.executeUpdate("INSERT INTO authordetails VALUES('"+txtAuthorID.getText()+"','"+txtAuthorName.getText()+"','"+gender+"','"+ftxtContactNo.getTe xt()+"','"+cmbBookCategory.getSelectedItem().toString()+"','"+cmbField.getSelectedItem().toString()+"',' "+txtNoBooks.getText()+"')"); } catch (SQLException ex) { Logger.getLogger(AuthorDeatils.class.getName()).log(Level.SEVERE, null, ex); } catch (ClassNotFoundException ex) { Logger.getLogger(AuthorDeatils.class.getName()).log(Level.SEVERE, null, ex); }

Update Button Code


private void btnUpdateActionPerformed(java.awt.event.ActionEvent evt) { try { String gender=""; Class.forName("com.mysql.jdbc.Driver"); Connection c = DriverManager.getConnection("jdbc:mysql://localhost:3306/bookpublication","root",""); Statement s= c.createStatement(); if (rdbMale.isSelected()) { gender = "Male"; } else if (rdbFemale.isSelected()) { gender = "Female"; } s.executeUpdate("UPDATE authordetails SET AuthorName = '"+txtAuthorName.getText()+"', Gender = '"+gender+"',ContactNo = '"+ftxtContactNo.getText()+"', BookCategoty = '"+cmbBookCategory.getSelectedItem().toString()+"', Field = '"+cmbField.getSelectedItem().toString()+"', NoofBooks = '"+txtNoBooks.getText()+"' WHERE AuthorID='"+txtAuthorID.getText()+"'"); } catch (SQLException ex) { Logger.getLogger(AuthorDeatils.class.getName()).log(Level.SEVERE, null, ex); } catch (ClassNotFoundException ex) { Logger.getLogger(AuthorDeatils.class.getName()).log(Level.SEVERE, null, ex); }

Delete Button Code


private void btnDeleteActionPerformed(java.awt.event.ActionEvent evt) { try { Class.forName("com.mysql.jdbc.Driver"); Connection c = DriverManager.getConnection("jdbc:mysql://localhost:3306/bookpublication","root",""); Statement s= c.createStatement(); s.executeUpdate("DELETE FROM authordetails WHERE AuthorID='"+txtAuthorID.getText()+"'"); } catch (SQLException ex) { Logger.getLogger(AuthorDeatils.class.getName()).log(Level.SEVERE, null, ex); } catch (ClassNotFoundException ex) { Logger.getLogger(AuthorDeatils.class.getName()).log(Level.SEVERE, null, ex); } }

Editor Details

Save Button Code


private void btnSaveActionPerformed(java.awt.event.ActionEvent evt) { try { String gender=""; Class.forName("com.mysql.jdbc.Driver"); Connection c = DriverManager.getConnection("jdbc:mysql://localhost:3306/bookpublication","root",""); Statement s = c.createStatement(); if (rdbMale.isSelected()) { gender = "Male"; } else if (rdbFemale.isSelected()) { gender = "Female"; } s.executeUpdate("INSERT INTO editordetails VALUES('"+txtEditorID.getText()+"','"+txtEditorName.getText()+"','"+gender+"','"+ftxtContactNo.getText( )+"','"+cmbBookCategory.getSelectedItem().toString()+"','"+cmbField.getSelectedItem().toString()+"','"+t xtNoBooks.getText()+"')"); } catch (SQLException ex) { Logger.getLogger(AuthorDeatils.class.getName()).log(Level.SEVERE, null, ex); } catch (ClassNotFoundException ex) { Logger.getLogger(AuthorDeatils.class.getName()).log(Level.SEVERE, null, ex); } }

Update Button Code


private void btnUpdateActionPerformed(java.awt.event.ActionEvent evt) { try { String gender=""; Class.forName("com.mysql.jdbc.Driver"); Connection c = DriverManager.getConnection("jdbc:mysql://localhost:3306/bookpublication","root",""); Statement s= c.createStatement(); if (rdbMale.isSelected()) { gender = "Male"; } else if (rdbFemale.isSelected()) { gender = "Female"; } s.executeUpdate("UPDATE editordetails SET EditorName = '"+txtEditorName.getText()+"', Gender = '"+gender+"',ContactNo = '"+ftxtContactNo.getText()+"', BookCategoty = '"+cmbBookCategory.getSelectedItem().toString()+"', Field = '"+cmbField.getSelectedItem().toString()+"', NoofBooks = '"+txtNoBooks.getText()+"' WHERE EditorID='"+txtEditorID.getText()+"'"); } catch (SQLException ex) { Logger.getLogger(AuthorDeatils.class.getName()).log(Level.SEVERE, null, ex); } catch (ClassNotFoundException ex) { Logger.getLogger(AuthorDeatils.class.getName()).log(Level.SEVERE, null, ex); } }

Delete Button Code


private void btnDeleteActionPerformed(java.awt.event.ActionEvent evt) {

try { Class.forName("com.mysql.jdbc.Driver"); Connection c = DriverManager.getConnection("jdbc:mysql://localhost:3306/bookpublication","root",""); Statement s= c.createStatement(); s.executeUpdate("DELETE FROM editordetails WHERE EditorID='"+txtEditorID.getText()+"'"); } catch (SQLException ex) { Logger.getLogger(AuthorDeatils.class.getName()).log(Level.SEVERE, null, ex); } catch (ClassNotFoundException ex) { Logger.getLogger(AuthorDeatils.class.getName()).log(Level.SEVERE, null, ex); } }

Book Details

Save Button Code


private void btnSaveActionPerformed(java.awt.event.ActionEvent evt) { try { Class.forName("com.mysql.jdbc.Driver"); Connection c = DriverManager.getConnection("jdbc:mysql://localhost:3306/bookpublication","root",""); Statement s = c.createStatement();

s.executeUpdate("INSERT INTO bookdetails VALUES('"+txtBookID.getText()+"','"+txtBookName.getText()+"','"+txtAuthorID.getText()+"','"+txtEditorI D.getText()+"','"+cmbBookCategory.getSelectedItem().toString()+"','"+cmbField.getSelectedItem().toStri ng()+"','"+txtCopiesAvalable.getText()+"')"); } catch (SQLException ex) { Logger.getLogger(AuthorDeatils.class.getName()).log(Level.SEVERE, null, ex); } catch (ClassNotFoundException ex) { Logger.getLogger(AuthorDeatils.class.getName()).log(Level.SEVERE, null, ex); } }

Update Button Code


private void btnUpdateActionPerformed(java.awt.event.ActionEvent evt) { try { Class.forName("com.mysql.jdbc.Driver"); Connection c = DriverManager.getConnection("jdbc:mysql://localhost:3306/bookpublication","root",""); Statement s= c.createStatement();

s.executeUpdate("UPDATE bookdetails SET BookName = '"+txtBookName.getText()+"', AuthorID = '"+txtAuthorID.getText()+"',EditorID = '"+txtEditorID.getText()+"', BookCategory = '"+cmbBookCategory.getSelectedItem().toString()+"', Field = '"+cmbField.getSelectedItem().toString()+"', CopiesAvailable = '"+txtCopiesAvalable.getText()+"' WHERE BookID='"+txtBookID.getText()+"'"); } catch (SQLException ex) { Logger.getLogger(AuthorDeatils.class.getName()).log(Level.SEVERE, null, ex); } catch (ClassNotFoundException ex) { Logger.getLogger(AuthorDeatils.class.getName()).log(Level.SEVERE, null, ex); } }

Delete Button Code


private void btnDeleteActionPerformed(java.awt.event.ActionEvent evt) { try { Class.forName("com.mysql.jdbc.Driver"); Connection c = DriverManager.getConnection("jdbc:mysql://localhost:3306/bookpublication","root",""); Statement s= c.createStatement(); s.executeUpdate("DELETE FROM bookdetails WHERE BookID='"+txtBookID.getText()+"'"); } catch (SQLException ex) { Logger.getLogger(AuthorDeatils.class.getName()).log(Level.SEVERE, null, ex); } catch (ClassNotFoundException ex) { Logger.getLogger(AuthorDeatils.class.getName()).log(Level.SEVERE, null, ex); } }

Outlet Details

Save Button Code


private void btnSaveActionPerformed(java.awt.event.ActionEvent evt) { try { Class.forName("com.mysql.jdbc.Driver"); Connection c = DriverManager.getConnection("jdbc:mysql://localhost:3306/bookpublication","root",""); Statement s = c.createStatement();

s.executeUpdate("INSERT INTO outletdetails VALUES('"+txtOutletID.getText()+"','"+txtOutletName.getText()+"','"+ftxtContactNo.getText()+"','"+txtNo Books.getText()+"')"); } catch (SQLException ex) { Logger.getLogger(AuthorDeatils.class.getName()).log(Level.SEVERE, null, ex); } catch (ClassNotFoundException ex) { Logger.getLogger(AuthorDeatils.class.getName()).log(Level.SEVERE, null, ex); } }

Update Button Code


private void btnUpdateActionPerformed(java.awt.event.ActionEvent evt) { try { Class.forName("com.mysql.jdbc.Driver"); Connection c = DriverManager.getConnection("jdbc:mysql://localhost:3306/bookpublication","root",""); Statement s= c.createStatement();

s.executeUpdate("UPDATE outletdetails SET OutletName = '"+txtOutletName.getText()+"', ContactNo = '"+ftxtContactNo.getText()+"', NoofBooks = '"+txtNoBooks.getText()+"' WHERE OutletID='"+txtOutletID.getText()+"'"); } catch (SQLException ex) { Logger.getLogger(AuthorDeatils.class.getName()).log(Level.SEVERE, null, ex); } catch (ClassNotFoundException ex) { Logger.getLogger(AuthorDeatils.class.getName()).log(Level.SEVERE, null, ex); } }

Delete Button Code


private void btnDeleteActionPerformed(java.awt.event.ActionEvent evt) { try { Class.forName("com.mysql.jdbc.Driver"); Connection c = DriverManager.getConnection("jdbc:mysql://localhost:3306/bookpublication","root",""); Statement s= c.createStatement(); s.executeUpdate("DELETE FROM outletdetails WHERE OutletID='"+txtOutletID.getText()+"'");

} catch (SQLException ex) { Logger.getLogger(AuthorDeatils.class.getName()).log(Level.SEVERE, null, ex); } catch (ClassNotFoundException ex) { Logger.getLogger(AuthorDeatils.class.getName()).log(Level.SEVERE, null, ex); } }

You might also like