Switch to full style
Project under GPL source codes are posted here
Post a reply

Java Library Database Management System Project

Fri Feb 01, 2013 1:08 am

* Project Name:   Library Database Management System Project
* Programmer:   msi_333
* Type:   Desktop Application
* Technology:  Java-SE
* IDE:   NetBeans
 Description:   This is a library database management using java under GPL2.0, this system is connect to database and has many features such as :
  • Add/Search/Modify/Remove records for the visitors of the library.
  • Add/Search/Modify/Remove records for the books.
  • Borrow and Return Books.
  • Search by publisher master.
  • Print the content of database in Table model (Per Each Table).
  • Based on the selected table(Tab) the buttons do different actions. For example if you on tab of book and press remove button it will open remove book dialog and different you was on another tab.
  • Jasper Report and Print Reports as HTML.
  • Connect to Microsoft SQL Server 2000 .
This project can be considered as teaching/learning goals.

Test.gif
Demo library management system
Test.gif (73.72 KiB) Viewed 55928 times

Following is a code sample:
java code
/*
* Main.java
*
* Created on December 14, 2006, 10:37 PM
*
* Copyright reserved to Codemiles.com ( GPL2.0)
* http://www.codemiles.com
*
*/

package connectingdatabase;


import ReportGen.ReportPanel;
import connectingdatabase.Search.AuthorSearch;
import connectingdatabase.Search.BookSearch;
import connectingdatabase.Search.BookStoreSearch;
import connectingdatabase.Search.PublisherSearch;
import connectingdatabase.Search.VisitorSearch;
import java.awt.BorderLayout;
import java.awt.Container;
import java.awt.Graphics;
import java.awt.Image;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.WindowEvent;
import java.awt.event.WindowListener;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.ResultSetMetaData;
import java.sql.SQLException;
import java.sql.Statement;
import java.util.ArrayList;
import javax.swing.Icon;
import javax.swing.ImageIcon;
import javax.swing.JButton;
import javax.swing.JDialog;
import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.JSplitPane;
import javax.swing.JTabbedPane;
import javax.swing.JTable;
import javax.swing.JTextArea;
import javax.swing.JToolBar;
import javax.swing.event.ChangeEvent;
import javax.swing.event.ChangeListener;
import javax.swing.table.AbstractTableModel;
import myMenuPack.myJMenu;



/**
*
* @author codemiles
*/
public class Main extends JFrame {

/** Creates a new instance of Main */
public Main()
{
start.show();
setTitle("DataBase Project");
setSize(800,700);
setLocation(200,0);

try {
Class.forName("com.microsoft.jdbc.sqlserver.SQLServerDriver");
System.out.println("Driver Exits !!!");

connection = DriverManager.getConnection(
"jdbc:microsoft:sqlserver://Casper:6666","msi_333","11991199");
Main.myArea.append("Connection Established !!!\n");
} catch (ClassNotFoundException ex) {
ex.printStackTrace();
}
catch (SQLException ex) {
Main.myArea.append(ex.toString());
}

Container cp=getContentPane();



myTables[0]=new VisitorTable(connection);
myTables[1]=new BookTable( connection);
myTables[2]=new AuthorTable(connection);
myTables[3]=new PublisherTable(connection);
myTables[4]=new BookStoreTable(connection);

mySP[0]=new JScrollPane(myTables[0],JScrollPane.VERTICAL_SCROLLBAR_ALWAYS,
JScrollPane.HORIZONTAL_SCROLLBAR_ALWAYS);

mySP[1]=new JScrollPane(myTables[1],JScrollPane.VERTICAL_SCROLLBAR_ALWAYS,
JScrollPane.HORIZONTAL_SCROLLBAR_ALWAYS);
mySP[2]=new JScrollPane(myTables[2],JScrollPane.VERTICAL_SCROLLBAR_ALWAYS,
JScrollPane.HORIZONTAL_SCROLLBAR_ALWAYS);
mySP[3]=new JScrollPane(myTables[3],JScrollPane.VERTICAL_SCROLLBAR_ALWAYS,
JScrollPane.HORIZONTAL_SCROLLBAR_ALWAYS);
mySP[4]=new JScrollPane(myTables[4],JScrollPane.VERTICAL_SCROLLBAR_ALWAYS,
JScrollPane.HORIZONTAL_SCROLLBAR_ALWAYS);

myToolbar =new myToolbar(tabbedPane,this,connection);

tabbedPane.addTab("Vistor", mySP[0]);

tabbedPane.addTab("Book", mySP[1]);
tabbedPane.addTab("Author", mySP[2]);
tabbedPane.addTab("Publisher", mySP[3]);
tabbedPane.addTab("Book Store", mySP[4]);

tabbedPane.addChangeListener(new ChangeListener() {
public void stateChanged(ChangeEvent e) {
switch(tabbedPane.getSelectedIndex())
{
case 0:((VisitorTable)(myTables[0])).ChangeModel() ;break;
case 1:((BookTable)(myTables[1])).ChangeModel();break;
case 2:((AuthorTable)(myTables[2])).ChangeModel();break;
case 3:((PublisherTable)(myTables[3])).ChangeModel();break;
case 4:((BookStoreTable)(myTables[4])).ChangeModel();break;

default :break;
}

}
});
mySplitePane=new JSplitPane(JSplitPane.VERTICAL_SPLIT,tabbedPane,myControlArea);
cp.add(myToolbar,BorderLayout.NORTH);
cp.add(mySplitePane);


addWindowListener(new WindowListener() {
public void windowActivated(WindowEvent e) {
}
public void windowClosed(WindowEvent e) {
}
public void windowClosing(WindowEvent e) {
Main.myArea.append("Connection Closed !!!\n") ;
try {
if(connection!=null) {
connection.close();
}

} catch (SQLException ex) {
ex.printStackTrace();
}

}
public void windowDeactivated(WindowEvent e) {
}
public void windowDeiconified(WindowEvent e) {
}
public void windowIconified(WindowEvent e) {
}
public void windowOpened(WindowEvent e) {
}
});


start.dispose();
setJMenuBar(myJM);
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
setVisible(true);


}

/**
* @param args the command line arguments
*/
public static void main(String[] args) {

// TODO code application logic here

new Main();
}


public static Connection connection;
private JTabbedPane tabbedPane=new JTabbedPane();

public static JTextArea myArea=new JTextArea(1,1);
private JScrollPane myControlArea=new JScrollPane(myArea,JScrollPane.VERTICAL_SCROLLBAR_ALWAYS
,JScrollPane.HORIZONTAL_SCROLLBAR_ALWAYS);
private JSplitPane mySplitePane;
private JPanel[] myTables=new JPanel[5];
private JScrollPane[] mySP=new JScrollPane[5];
private myToolbar myToolbar ;
private myJMenu myJM=new myJMenu();
public static String CompName="Casper";
public static String Port="6666";
private myStart start=new myStart();
}


class myToolbar extends JToolBar
{
public myToolbar(final JTabbedPane Tabbed,final JFrame myMother,final Connection conn)
{
// setLayout(null);

AddImag=new ImageIcon("icons/Add.png");

SearchImag=new ImageIcon("icons/Search.png");
ModifyImag=new ImageIcon("icons/Modify.png");
RemoveImag=new ImageIcon("icons/Remove.png");
BorrowImag=new ImageIcon("icons/Borrow.png");
ReturnImag=new ImageIcon("icons/Return.png");
ReportImag=new ImageIcon("icons/Report.png");
MasterImag=new ImageIcon("icons/Master.png");

AddBut=new JButton("Add", AddImag);
SearchBut=new JButton("Search",SearchImag);
ModifyBut=new JButton("Modify",ModifyImag);
RemoveBut=new JButton("Remove",RemoveImag);
BorrowBut=new JButton("Borrow",BorrowImag);
ReturnBut=new JButton("Return",ReturnImag);
ReportBut=new JButton("Report",ReportImag);
MasterBut=new JButton("Master",MasterImag);
AddBut.setAlignmentY(CENTER_ALIGNMENT);
SearchBut.setAlignmentY(CENTER_ALIGNMENT);
ModifyBut.setAlignmentY(CENTER_ALIGNMENT);
RemoveBut.setAlignmentY(CENTER_ALIGNMENT);
ReturnBut.setAlignmentY(CENTER_ALIGNMENT);
ReportBut.setAlignmentY(CENTER_ALIGNMENT);
MasterBut.setAlignmentY(CENTER_ALIGNMENT);
add(AddBut);
add(SearchBut);
add(ModifyBut);
add(RemoveBut);
add(BorrowBut);
add(ReturnBut);
add(ReportBut);
add(MasterBut);
AddBut.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e)
{


switch(Tabbed.getSelectedIndex())
{
case 0:((new VisitorPanel(conn,myMother))).show();break;
case 1:(new BookPanel(conn,myMother)).show();break;
case 2:(new AuthorPanel(conn,myMother)).show();break;
case 3:(new PublisherPanel(conn,myMother)).show();break;
case 4:(new BookStorePanel(conn,myMother)).show();break;

default :break;
}

}
});
SearchBut.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {


switch(Tabbed.getSelectedIndex())
{
case 0:(new VisitorSearch(conn,myMother)).show();break;
case 1:(new BookSearch(conn,myMother)).show();break;
case 2:(new AuthorSearch(conn,myMother)).show();break;
case 3:(new PublisherSearch(conn,myMother)).show();break;
case 4:(new BookStoreSearch(conn,myMother)).show();break;

default :break;
}


}
});
ModifyBut.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {



switch(Tabbed.getSelectedIndex())
{
case 0:(new VisitorModifyPanel(conn,myMother)).show();break;
case 1:(new BookModifyPanel(conn,myMother)).show();break;
case 2:(new AuthorModifyPanel(conn,myMother)).show();break;
case 3:(new PublisherModifyPanel(conn,myMother)).show();break;
case 4:(new BookStoreModifyPanel(conn,myMother)).show();break;

default :break;
}

}
});
RemoveBut.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {



switch(Tabbed.getSelectedIndex())
{
case 0:(new VisitorRemovePanel(conn,myMother)).show();break;
case 1:(new BookRemovePanel(conn,myMother)).show();break;
case 2:(new AuthorRemovePanel(conn,myMother)).show();break;
case 3:(new PublisherRemovePanel(conn,myMother)).show();break;
case 4:(new BookStoreRemovePanel(conn,myMother)).show();break;

default :break;
}
}
});

BorrowBut.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e)
{
new BorrowBookPanel(conn,myMother).show();
}
});

ReturnBut.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {

new ReturnedBookPanel(conn,myMother).show();
}
});

ReportBut.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
new ReportPanel(conn,myMother).show();
}
});
MasterBut.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
new BKStoreMaster(conn,myMother).show();
}
});

}



private JButton AddBut ;
private JButton SearchBut ;
private JButton ModifyBut ;
private JButton RemoveBut ;
private JButton BorrowBut ;
private JButton ReturnBut ;
private JButton ReportBut ;
private JButton MasterBut ;
private Icon AddImag;
private Icon SearchImag;
private Icon ModifyImag;
private Icon RemoveImag;
private Icon BorrowImag;
private Icon ReturnImag;
private Icon ReportImag;
private Icon MasterImag;
}
class myStart extends JDialog
{
myStart()
{

setUndecorated(true);
// setIgnoreRepaint(true);
setResizable(false);
setSize(150,150);
setLocation(400,300);

}

private Image Imgstart=new ImageIcon("icons/back.png").getImage();
public void paint(Graphics g) {
g.drawImage(Imgstart,0,0,this);
}
}


All the needed Jars are in the project archive. Here is the database SQL/DML :

sql code
/*==============================================================*/
/* Database name: ConceptualDataModel_4 */
/* DBMS name: Microsoft SQL Server 2000 */
/* Created on: 12/17/2006 8:02:06 AM */
/*==============================================================*/


/*==============================================================*/
/* Table: Author */
/*==============================================================*/
create table Author (
A_ID int not null,
Name text null,
Adress text null,
"Phone.no" bigint null,
Nationality text null,
constraint PK_AUTHOR primary key (A_ID)
)
go


/*==============================================================*/
/* Table: Book */
/*==============================================================*/
create table Book (
B_ID int not null,
P_ID int not null,
Title text null,
No_of_Copies int null,
Price int null,
ISBN text null,
Type text null,
constraint PK_BOOK primary key (B_ID)
)
go


/*==============================================================*/
/* Index: publish_FK */
/*==============================================================*/
create index publish_FK on Book (
P_ID
)
go


/*==============================================================*/
/* Table: Book_store */
/*==============================================================*/
create table Book_store (
BS_ID int not null,
Storage_Space int null,
Phone_no text null,
Address text null,
constraint PK_BOOK_STORE primary key (BS_ID)
)
go


/*==============================================================*/
/* Table: Borrow */
/*==============================================================*/
create table Borrow (
ID int not null,
memberChip_Serial varchar(1) not null,
B_ID int not null,
constraint PK_BORROW primary key (ID, memberChip_Serial, B_ID)
)
go


/*==============================================================*/
/* Index: Borrow_FK */
/*==============================================================*/
create index Borrow_FK on Borrow (
ID,
memberChip_Serial
)
go


/*==============================================================*/
/* Index: Borrow2_FK */
/*==============================================================*/
create index Borrow2_FK on Borrow (
B_ID
)
go


/*==============================================================*/
/* Table: Contain */
/*==============================================================*/
create table Contain (
BS_ID int not null,
B_ID int not null,
constraint PK_CONTAIN primary key (BS_ID, B_ID)
)
go


/*==============================================================*/
/* Index: Contain_FK */
/*==============================================================*/
create index Contain_FK on Contain (
BS_ID
)
go


/*==============================================================*/
/* Index: Contain2_FK */
/*==============================================================*/
create index Contain2_FK on Contain (
B_ID
)
go


/*==============================================================*/
/* Table: Member */
/*==============================================================*/
create table Member (
ID int not null,
memberChip_Serial varchar(1) not null,
payment money null,
memberChip_End datetime null,
numOf_BorrBook int null,
Name text null,
Address text null,
Phone char(11) null,
Age int null,
Gander text null,
isMember bit null,
constraint PK_MEMBER primary key (ID, memberChip_Serial)
)
go


/*==============================================================*/
/* Index: Inheritance_1_FK */
/*==============================================================*/
create index Inheritance_1_FK on Member (
ID
)
go


/*==============================================================*/
/* Table: Publisher */
/*==============================================================*/
create table Publisher (
P_ID int not null,
Name text null,
Country text null,
Address text null,
"Phone.no" bigint null,
constraint PK_PUBLISHER primary key (P_ID)
)
go


/*==============================================================*/
/* Table: Visitor */
/*==============================================================*/
create table Visitor (
ID int not null,
Name text null,
Address text null,
Phone char(11) null,
Age int null,
Gander text null,
isMember bit null,
constraint PK_VISITOR primary key (ID)
)
go


/*==============================================================*/
/* Table: Write */
/*==============================================================*/
create table Write (
A_ID int not null,
B_ID int not null,
constraint PK_WRITE primary key (A_ID, B_ID)
)
go


/*==============================================================*/
/* Index: Write_FK */
/*==============================================================*/
create index Write_FK on Write (
A_ID
)
go


/*==============================================================*/
/* Index: Write2_FK */
/*==============================================================*/
create index Write2_FK on Write (
B_ID
)
go


alter table Book
add constraint FK_BOOK_PUBLISH_PUBLISHE foreign key (P_ID)
references Publisher (P_ID)
go


alter table Borrow
add constraint FK_BORROW_BORROW_MEMBER foreign key (ID, memberChip_Serial)
references Member (ID, memberChip_Serial)
go


alter table Borrow
add constraint FK_BORROW_BORROW2_BOOK foreign key (B_ID)
references Book (B_ID)
go


alter table Contain
add constraint FK_CONTAIN_CONTAIN_BOOK_STO foreign key (BS_ID)
references Book_store (BS_ID)
go


alter table Contain
add constraint FK_CONTAIN_CONTAIN2_BOOK foreign key (B_ID)
references Book (B_ID)
go


alter table Member
add constraint FK_MEMBER_INHERITAN_VISITOR foreign key (ID)
references Visitor (ID)
go


alter table Write
add constraint FK_WRITE_WRITE_AUTHOR foreign key (A_ID)
references Author (A_ID)
go


alter table Write
add constraint FK_WRITE_WRITE2_BOOK foreign key (B_ID)
references Book (B_ID)
go



Attachments
LibraryWithDataBase.zip
NetBeans Project.
(2.67 MiB) Downloaded 20813 times

Post a reply
  Related Posts  to : Java Library Database Management System Project
 how to create a photo management system using java     -  
 chat system project in java using netbeans     -  
 application on hotel management system     -  
 need project code for time and work management     -  
 Templates database Website Project     -  
 C++ & Java memory management!!     -  
 mail system in java     -  
 How to get system time in java     -  
 Abbreviations System java     -  
 Customer Controls System in Java     -  

Topic Tags

Java JDBC, Java Swing