Library Management Project
Library Management Project
ANGUL
INFORMATICS PRACTICES
PROJECT
2019-20
LIBRARY MANAGEMENT
Submitted to Submitted by
MISS DOLLY NAYAK Name : SATYABRATA DWIVEDY
We hope that the present application will cater
the needs of librarian and students as a matter
of fact, we would feel rewarded if this
application is found helpful to the users .All the
attempts have been made to make this
application error free.
if(username.isEmpty() )
JOptionPane.showMessageDialog(this,"Username is not entered");
else
if(password.isEmpty())
JOptionPane.showMessageDialog(this,"Password is not entered");
else
{
try
{
Class.forName("java.sql.DriverManager");
Connection con = (Connection)
DriverManager.getConnection("jdbc:mysql://localhost:3306/libman","root","password
");
Statement stmt = (Statement)con.createStatement();
String query = "Select username,password from account where
username='"+username+"';";
ResultSet rs=stmt.executeQuery(query);
if(rs.next())
{
Username = rs.getString("username");
Password = rs.getString("password");
}
}
catch(Exception e)
{
JOptionPane.showMessageDialog(this,e.getMessage());
}
if (username.equals(Username) && password.equals(Password))
{
this.setVisible((false));
mainpage a = new mainpage();
a.setVisible(true);
}
else
{
JOptionPane.showMessageDialog(this,"either your username or password
is wrong");
jTextField1.setText(null);
jPasswordField1.setText(null);
}
}
}
Code for “CREATE” button:
if(name.isEmpty() )
JOptionPane.showMessageDialog(this,"Name is not entered");
else
if (username.isEmpty())
JOptionPane.showMessageDialog(this, "Username is not entered");
else
if(password.isEmpty())
JOptionPane.showMessageDialog(this,"Password is not entered");
else
if (repassword.isEmpty())
JOptionPane.showMessageDialog(this,"You have to re-enter your
password");
else
if (mobile.isEmpty())
JOptionPane.showMessageDialog(this,"Mobile number is not entered");
else
{
if(password.equals(repassword))
{
try
{
Class.forName("java.sql.DriverManager");
Connection con = (Connection)
DriverManager.getConnection("jdbc:mysql://localhost:3306/libman","root","password
");
Statement stmt = (Statement) con.createStatement();
String query = "insert into account values
('"+name+"','"+username+"','"+mobile+"','"+password+"');";
stmt.executeUpdate(query);
if(accno.isEmpty() )
JOptionPane.showMessageDialog(this,"Accession no. is not entered");
else
if (book.isEmpty())
JOptionPane.showMessageDialog(this, "Book name is not entered");
else
if(author.isEmpty())
JOptionPane.showMessageDialog(this,"Author name is not entered");
else
if (cost.isEmpty())
JOptionPane.showMessageDialog(this,"price of the book is not entered");
else
{
try
{
Class.forName("java.sql.DriverManager");
Connection con = (Connection)
DriverManager.getConnection("jdbc:mysql://localhost:3306/libman","root","password
");
Statement stmt = (Statement) con.createStatement();
String query1 = "insert into books values
('"+accno+"','"+book+"','"+author+"','"+cost+"');";
String query2 = "insert into issue values('0','"+accno+"','0','1');";
stmt.executeUpdate(query1);
stmt.executeUpdate(query2);
JOptionPane.showMessageDialog(this," thank you , a new book has been
successfully added");
}
catch(Exception e)
{
JOptionPane.showMessageDialog(this,e.getMessage());
}
}
}
private void
jButton11ActionPerformed(java.awt.event.ActionEvent evt) {
String admnno = jTextField5.getText();
String studentname = jTextField6.getText();
try
{
Class.forName("java.sql.DriverManager");
Connection con = (Connection)
DriverManager.getConnection("jdbc:mysql://localhost:3306/libman","root","password
");
Statement stmt = (Statement) con.createStatement();
String query = "insert into student values
('"+admnno+"','"+studentname+"');";
stmt.executeUpdate(query);
}
catch(Exception e)
{
JOptionPane.showMessageDialog(this,e.getMessage());
}
try
{
Class.forName("java.sql.DriverManager");
Connection con = (Connection)
DriverManager.getConnection("jdbc:mysql://localhost:3306/libman","root","password
");
Statement stmt = (Statement) con.createStatement();
String query1 = "insert into issue values
('"+admno+"','"+accno+"','"+isdate+"','0');";
String query2 = "select rdate from issue where accno = '"+accno+"'; ";
ResultSet rs = stmt.executeQuery(query2);
if(rs.last())
{
String date = rs.getString("rdate");
if(date.equals("0"))
JOptionPane.showMessageDialog(this,"this book has already been
issued to someone else");
else
{
stmt.executeUpdate(query1);
JOptionPane.showMessageDialog(this,"a book has been issued to " +
jTextField6.getText());
}
}
catch(Exception e)
{
JOptionPane.showMessageDialog(this,e.getMessage());
}
}
else if (jRadioButton2.isSelected())
{
rsdate = jTextField9.getText();
try
{
Class.forName("java.sql.DriverManager");
Connection con = (Connection)
DriverManager.getConnection("jdbc:mysql://localhost:3306/libman","root","password
");
Statement stmt = (Statement) con.createStatement();
String query = "update issue set rdate = '"+rsdate+"' where admnno =
'"+admno+"' and accno = '"+accno+"';";
stmt.executeUpdate(query);
JOptionPane.showMessageDialog(this,"Mr."+jTextField6.getText()+" has
returned a book named "+jTextField8.getText());
}
catch(Exception e)
{
JOptionPane.showMessageDialog(this,e.getMessage());
}
}
DefaultTableModel model = (DefaultTableModel) jTable2.getModel();
int rows = model.getRowCount();
if(rows > 0 )
{
for(int i = 0 ;i < rows ;i++)
model.removeRow(0);
}
Backend :
Table : “BOOKS”
Table : “STUDENT”
Table : “ACCOUNTS”