Beruflich Dokumente
Kultur Dokumente
entitled
RAILWAY RESERVATION SYSTEM
INFORMATICS PRACTICES (065)
AISSCE(2018-19)
candidate.
ROLL NO:
GUIDED BY
Mr. A.K. Pandey
(Head of Computer Dept.)
3
ACKNOWLEDGEMENT
undertook this Project work, as the part of my XII-
Informatics Practices course.We had tried to apply my
best of knowledge and experience, gained during the
study and class work experience. However, developing
software system is generally a quite complex and time-
consuming process. It requires a systematic study, insight
vision and professional approach during the design and
development. Moreover, the developer always feels the
need, the help and good wishes of the people near you,
who have considerable experience and idea.
1. Introduction ------------------------------------------ 5
5.Bibliography ---------------------------------------- 61
5
1. Introduction
This software project is developed to automate the functionalities of
program is tied with the database for easy access and interface to
This software, being simple in design and working, does not require
6
2. Theoretical Background
3.1 What is Database?
Introduction and Concepts:
A database is a collection of information related to a
particular subject or purpose, such as tracking customer
orders or maintaining a music collection. Using any RDBMS
application software like MS SQL Server, MySQL, Oracle,
Sybase etc, you can manage all your information from a
single database file. Within the file, divide your data into
separate storage containers called tables. You may and
retrieve the data using queries.
A table is a collection of data about a specific topic, such as
products or suppliers. Using a separate table for each topic
means you can store that data only once, which makes your
database more efficient and reduces data-entry errors. Table
organises data into columns (called fields) and rows (called
records).
A Primary key is one or more fields whose value or values
uniquely identify each record in a table. In a relationship, a
primary key is used to refer to specific record in one table
from another table. A primary key is called foreign key when
it is referred to from another table.
7
To find and retrieve just the data that meets conditions you
specify, including data from multiple tables, create a query. A
query can also update or delete multiple records at the same
time, and perform built-in or custom calculations on your
data.
NETWORK TOPOLOGY
It is the arrangement of the various elements (links, nodes,
etc.) of a computer network. Essentially, it is the
topological structure of a network and may be depicted
physically or logically.
There are a number of different types of network topologies,
including point-to-point, bus, star, ring, mesh, tree and
hybrid.
8
Advantages:
o Ease of Service.
o One device per connection.
o Centralized control.
Disadvantages:
o Long cable length.
o Difficult to expand.
o Central node dependency.
9
Open Source Software being used in our School:
INTRODUCTION
Java is a popular third-generation programming
language, which can be used to perform any of the
thousands of things that computer software can do.
With the features it offers, Java has become the
10
language choice of Internet and Intranet applications.
Java plays an important role for the proper functioning
of many software-based devices attached to
network.The kind of functionality the Java offers, has
contributed a lot towards the popularity of Java.
11
BYTE CODE
Whenever a program written in the Java Programming
Language is compiled, the compiler converts the
human readable source file into platform independent
code that JVM(Java Virtual Machine) can understand.
This platform independent code is called byte code.
*******
12
MySQL SERVER 5.1
(BACK END SOFTWARE)
INTRODUCTION
A database is basically a computer-based record
keeping system. The collection of data, usually
referred to as a database, contains information about
one particular enterprise. It maintains any information
that may be necessary to the decision-making process
involved in the management of that organization. A
database may also be defined as collection of
interrelated data stored together to several multiple
applications; the data is such stored so that it is
independent of the program which uses the data; a
common and controlled approach is used in adding
new data and modifying and retrieving data within the
database. The data is structured so as to provide a
foundation for future application development. The
intention of a database is that the same collection of
data should serve as many applications as possible.
13
DATABASE MANAGEMENT SYSTEM
A Database Management System (DBMS) refers to
software that is responsible for storing, maintaining
and
utilizing databases. A database along with a DBMS is
referred as Database System.
ADVANTAGES
Reduce the data redundancy to a larger extent:
Data redundancy means the duplication of data.
Non-database systems maintain separate copies of
data for each application.
Can control data inconsistency to a large extent:
When the redundancy is not controlled there may
be occasions on which the two entries do not
agree. At such time database is said to be
inconsistent.
Facilitate sharing of data:
Sharing of data means that the individual pieces of
data in the database may be shared among several
different users, in the sense that each may have
access to the same piece of data and each of them
may use it for different purposes.
Enforce standards:
The database management system can ensure that
all data follow the application standards.
14
Integrity can be maintained:
Integrated database means unification of servers
otherwise distinct files, with any redundancy
among those files partially or wholly eliminated.
Can ensures data security:
COMMANDS
Data Definition Language (DDL) Commands:
o Commands that allow us to perform task
related to data definition. For example:
creating, altering and dropping
maintenance commands
Data Manipulation Language (DML) Commands:
o Commands that allow us to perform data
manipulation. For example:
retrieval insertion
deletion
modification
Transaction Control Language (TCL) Commands:
o Commands that allow us to manage and
control the transactions (one complete unit of
work involving many steps). For example:
making changes to database, permanent
undoing changes to database, permanent
creating save points
15
3. System Implementation
16
TABLE STRUCTURE
LOGIN DETAILS
SAMPLE DATA
17
INFO TABLE
SAMPLE DATA
18
RECORD TABLE
SAMPLE DATA
19
(1) LOGIN PAGE
IMPORT COMMANDS
import java.sql.*;
import java.lang.*;
import javax.swing.JOptionPane;
CODING:
private void
loginBTNActionPerformed(java.awt.event.ActionEvent evt) {
String uname=nameTF.getText();
try{
20
Class.forName("java.sql.Driver");
Connection
con=DriverManager.getConnection("jdbc:mysql://localhost:3306/railway","root","ad
min");
Statement stmt=con.createStatement();
ResultSet rs;
while(rs.next()) {
if
(pass.equalsIgnoreCase(rs.getString("pass"))&&uname.equalsIgnoreCase(rs.getString
("uname")))
{new intro().setVisible(true);
this.dispose();}
else
System.out.print("wrong"); }
con.close();
private void
manageAccBTNActionPerformed(java.awt.event.ActionEvent
evt) {
new manageAcc().setVisible(true);
21
private void
jMenu4ActionPerformed(java.awt.event.ActionEvent evt) {
private void
jMenuItem3ActionPerformed(java.awt.event.ActionEvent evt) {
22
(2) START PAGE
CODING:
private void
jButton1ActionPerformed(java.awt.event.ActionEvent evt) {
new loading().setVisible(true); // TODO add your handling code here:
this.dispose();
23
(3) LOADING PAGE
CODING:
private void
goBTNActionPerformed(java.awt.event.ActionEvent evt) {
new homescreen().setVisible(true);
24
(4) HOME SCREEN
CODING:
private void
exitMIActionPerformed(java.awt.event.ActionEvent evt) {
private void
jMenu4ActionPerformed(java.awt.event.ActionEvent evt) {
25
private void
bookTicketMIActionPerformed(java.awt.event.ActionEvent evt)
{
this.dispose();
private void
CancelTicketMIActionPerformed(java.awt.event.ActionEv
ent evt) {
this.dispose();
private void
DisplayRecordsMIActionPerformed(java.awt.event.ActionEvent
evt) {
this.dispose();
private void
addTrianInfoMIActionPerformed(java.awt.event.ActionEvent
evt) {
this.dispose();
26
private void
checkTrainInfoMIActionPerformed(java.awt.event.ActionEvent
evt) {
this.dispose();
private void
SignOutMIActionPerformed(java.awt.event.ActionEvent evt) {
this.dispose();
private void
homeScreenMIActionPerformed(java.awt.event.ActionEvent
evt) {
this.dispose();
27
(5) TICKET BOOKING
IMPORT COMMAND:
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.Statement;
import javax.swing.JOptionPane;
CODING:
private void
jButton1ActionPerformed(java.awt.event.ActionEvent evt) {
System.out.println(random);
28
if (boardRB.getSelectedIndex()==destinationRB.getSelectedIndex()
||(monthRB.getSelectedIndex()==0)||yearRB.getSelectedIndex()==0||dayRB.getSelected
Index()==0)
else {
if(random%5==0){
trainRB.removeItem(trainRB.getSelectedItem());}
else {
netAmountBTN.setEnabled(true);
JOptionPane.showMessageDialog(null,"TRAINS AVAILABLE");
String date=("'"+year+"-"+month+"-"+day+"'");
double seats=seatRB.getSelectedIndex()+1;
double Trate=trainRB.getSelectedIndex();
double ac=acRB.getSelectedIndex()+1;
double single_amnt=(2000+(2000*(4.5*Trate/100)));
double ac_amnt=single_amnt+single_amnt+750*ac;
double net_amnt=Math.abs(ac_amnt*seats);
System.out.println(net_amnt);
proceedBTN.setText(""+net_amnt);
*/
29
}
private void
netAmountBTNActionPerformed(java.awt.event.ActionEvent
evt) {
String year =(String) yearRB.getSelectedItem();
String date=(""+year+"-"+month+"-"+day+"");
double seats=seatRB.getSelectedIndex()+1;
double Trate=trainRB.getSelectedIndex();
double ac=acRB.getSelectedIndex()+1;
double single_amnt=(2000+(2000*(4.5*Trate/100)));
double ac_amnt=single_amnt+single_amnt+750*ac;
double net_amnt=Math.abs(ac_amnt*seats);
netLBL.setText(""+net_amnt);
private void
bookBTNActionPerformed(java.awt.event.ActionEvent evt) {
double seats=seatRB.getSelectedIndex();int newRecord=0;long PNR=0;
30
String month = (String) monthRB.getSelectedItem();
String date=(""+year+"-"+month+"-"+day+"");
double acType=acRB.getSelectedIndex()+1;
try{
Class.forName("java.sql.Driver");
Connection
con=DriverManager.getConnection("jdbc:mysql://localhost:3306/railway","root","ad
min");
Statement stmt=con.createStatement();
rs.last();
PNR=rs.getInt("PNR")+123;
con.close();
for(int i=0;i<=seats;i++){
31
System.out.println("insert into records
values("+PNR+",'"+name+"',"+age+",'"+sex+"','"+train+"','"+date+"','"+board+"','"+desti
nation+"',"+acType+");");
try{
Class.forName("java.sql.Driver");
Connection
con=DriverManager.getConnection("jdbc:mysql://localhost:3306/railway","root","ad
min");
Statement stmt=con.createStatement();
ResultSet rs=null;
if(choice==0){
}con.close();
private void
jCheckBox1ActionPerformed(java.awt.event.ActionEvent evt) {
if (jCheckBox1.isSelected())
bookBTN.setEnabled(true);
if (jCheckBox1.isSelected()==false)
bookBTN.setEnabled(false);
32
// TODO add your handling code here:
private void
bookTicketMIActionPerformed(java.awt.event.ActionEvent evt)
{
this.dispose();
private void
CancelTicketMIActionPerformed(java.awt.event.ActionEvent
evt) {
this.dispose();
private void
DisplayRecordsMIActionPerformed(java.awt.event.ActionEvent evt) {
this.dispose();
private void
addTrianInfoMIActionPerformed(java.awt.event.ActionEvent
evt) {
this.dispose();
33
new addTrainInfo().setVisible(true); // TODO add your handling code
here:
private void
checkTrainInfoMIActionPerformed(java.awt.event.ActionEvent
evt) {
this.dispose();
private void
SignOutMIActionPerformed(java.awt.event.ActionEvent evt) {
this.dispose();
private void
homeScreenMIActionPerformed(java.awt.event.ActionEvent
evt) {
this.dispose();
private void
exitMIActionPerformed(java.awt.event.ActionEvent evt) {
34
System.exit(0); // TODO add your handling code here:
private void
jMenu4ActionPerformed(java.awt.event.ActionEvent evt) {
35
(6) CANCEL TICKET
IMPORT COMMAND:
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.Statement;
import javax.swing.JOptionPane;
import javax.swing.table.DefaultTableModel;
CODING:
int PNR;
private void
formWindowOpened(java.awt.event.WindowEvent evt) {
36
PNR=Integer.parseInt(JOptionPane.showInputDialog("ENTER YOUR PNR
NUMBER")); // TODO add your handling code here:
boolean exist=false;
try {
Class.forName("com.mysql.jdbc.Driver").newInstance();
ResultSet rs = stmt.executeQuery(query);
while (rs.next()) {
if (rs.getInt("pnr")==PNR)
exist=true;
break;}
} catch (Exception e) {
JOptionPane.showMessageDialog(this, e.getMessage());
if (exist==true){
try {
Class.forName("com.mysql.jdbc.Driver").newInstance();
ResultSet rs = stmt.executeQuery(query);
37
while (rs.next()) {
PNRTF.setText(""+PNR);
PNAME.setText(pname);
PSEX.setText(psex);
TNAME.setText(tname);
DATETF.setText(date);
FROMTF.setText(board);
TOTF.setText(destination);
ACTYPETF.setText(acType);
} catch (Exception e) {
JOptionPane.showMessageDialog(this, e.getMessage());
}}
else{
new cancelTicket().setVisible(true);
38
}
private void
jButton1ActionPerformed(java.awt.event.ActionEvent evt) {
if(choice==0) {
try{
Class.forName("java.sql.Driver");
Connection
con=DriverManager.getConnection("jdbc:mysql://localhost:3306/railway","root","ad
min");
Statement stmt=con.createStatement();
ResultSet rs=null;
con.close();
private void
bookTicketMIActionPerformed(java.awt.event.ActionEvent evt)
{
this.dispose();
39
private void
CancelTicketMIActionPerformed(java.awt.event.ActionEvent
evt) {
this.dispose();
private void
DisplayRecordsMIActionPerformed(java.awt.event.ActionEvent
evt) {
this.dispose();
private void
addTrianInfoMIActionPerformed(java.awt.event.ActionEvent
evt) {
this.dispose();
private void
checkTrainInfoMIActionPerformed(java.awt.event.ActionEvent
evt) {
this.dispose();
40
private void
SignOutMIActionPerformed(java.awt.event.ActionEvent evt) {
this.dispose();
private void
homeScreenMIActionPerformed(java.awt.event.ActionEvent
evt) {
this.dispose();
private void
exitMIActionPerformed(java.awt.event.ActionEvent evt) {
System.exit(0); // TODO add your handling code here:
private void
jMenu4ActionPerformed(java.awt.event.ActionEvent evt) {
41
(7) DISPLAY RECORD
IMPORT COMMAND:
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.Statement;
import javax.swing.JOptionPane;
import javax.swing.table.DefaultTableModel;
CODING;
private void
displayBTNActionPerformed(java.awt.event.ActionEvent evt) {
42
DefaultTableModel model = (DefaultTableModel) recordTBL.getModel();
if (rows > 0) {
model.removeRow(0);
boolean exist=false;
try {
Class.forName("com.mysql.jdbc.Driver").newInstance();
ResultSet rs = stmt.executeQuery(query);
while (rs.next()) {
if (rs.getInt("pnr")==PNR)
exist=true;
break;}
} catch (Exception e) {
JOptionPane.showMessageDialog(this, e.getMessage());
if (exist==true){
43
try {
Class.forName("com.mysql.jdbc.Driver").newInstance();
ResultSet rs = stmt.executeQuery(query);
while (rs.next()) {
} catch (Exception e) {
JOptionPane.showMessageDialog(this, e.getMessage());
} } else
44
private void
bookTicketMI5ActionPerformed(java.awt.event.ActionEvent
evt) {
this.dispose();
private void
CancelTicketMIActionPerformed(java.awt.event.ActionEvent
evt) {
this.dispose();
private void
DisplayRecordsMIActionPerformed(java.awt.event.ActionEvent
evt) {
this.dispose();
private void
addTrianInfoMIActionPerformed(java.awt.event.ActionEvent
evt) {
this.dispose();
45
private void
checkTrainInfoMIActionPerformed(java.awt.event.ActionEvent
evt) {
this.dispose();
private void
SignOutMIActionPerformed(java.awt.event.ActionEvent evt) {
this.dispose();
private void
homeScreenMIActionPerformed(java.awt.event.ActionEvent
evt) {
this.dispose();
private void
exitMIActionPerformed(java.awt.event.ActionEvent evt) {
46
private void
jMenu10ActionPerformed(java.awt.event.ActionEvent evt) {
System.exit(0); // TODO add your handling code here:
47
(8) GET TRAIN INFO
IMPORT COMMAND:
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.Statement;
import javax.swing.JOptionPane;
CODING:
private void
Get_train_infoBTNActionPerformed(java.awt.event.ActionEvent
evt) {
48
String tname =(String) trainRB.getSelectedItem();
try {
Class.forName("com.mysql.jdbc.Driver").newInstance();
while (rs.next()) {
TnoTF.setText(tno);
PnoTF.setText(pno);
BoardTF.setText(BOARDING);
JtimeTF.setText(Journey);
} catch (Exception e) {
JOptionPane.showMessageDialog(this, e.getMessage());
49
private void
bookTicketMIActionPerformed(java.awt.event.ActionEvent evt)
{
this.dispose();
private void
CancelTicketMIActionPerformed(java.awt.event.ActionEvent
evt) {
this.dispose();
private void
DisplayRecordsMIActionPerformed(java.awt.event.ActionEvent
evt) {
this.dispose();
private void
addTrianInfoMIActionPerformed(java.awt.event.ActionEvent
evt) {
this.dispose();
50
}
private void
checkTrainInfoMIActionPerformed(java.awt.event.ActionEvent
evt) {
this.dispose();
private void
SignOutMIActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
this.dispose();
private void
homeScreenMIActionPerformed(java.awt.event.ActionEvent
evt) {
this.dispose();
private void
exitMIActionPerformed(java.awt.event.ActionEvent evt) {
51
private void
jMenu4ActionPerformed(java.awt.event.ActionEvent evt) {
System.exit(0); // TODO add your handling code here:
52
(9) ADD TRAIN INFO
IMPORT COMMAND:
import java.sql.*;
import javax.swing.JOptionPane;
CODING:
53
private void
Get_train_infoBTNActionPerformed(java.awt.event.ActionEvent
evt) {
String tname =Tname.getText();
try {
Class.forName("com.mysql.jdbc.Driver").newInstance();
ResultSet rs =null;
int newRecord;
if(choice==0){
} }catch (Exception e) {
JOptionPane.showMessageDialog(this, e.getMessage());
54
}
private void
bookTicketMIActionPerformed(java.awt.event.ActionEvent evt)
{
this.dispose();
private void
CancelTicketMIActionPerformed(java.awt.event.ActionEvent
evt) {
this.dispose();
private void
DisplayRecordsMIActionPerformed(java.awt.event.ActionEvent
evt) {
this.dispose();
55
private void
addTrianInfoMIActionPerformed(java.awt.event.ActionEvent
evt) {
this.dispose();
private void
checkTrainInfoMIActionPerformed(java.awt.event.ActionEvent
evt) {
this.dispose();
private void
SignOutMIActionPerformed(java.awt.event.ActionEvent evt) {
this.dispose();
private void
homeScreenMIActionPerformed(java.awt.event.ActionEvent
evt) {
this.dispose();
56
}
private void
exitMIActionPerformed(java.awt.event.ActionEvent evt) {
private void
jMenu4ActionPerformed(java.awt.event.ActionEvent evt) {
System.exit(0); // TODO add your handling code here:
57
(10) CREATE NEW ID
IMPORT:
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.Statement;
import javax.swing.JOptionPane;
CODING:
private void
createBTNActionPerformed(java.awt.event.ActionEvent evt) {
58
try{
Class.forName("java.sql.Driver");
Connection
con=DriverManager.getConnection("jdbc:mysql://localhost:3306/railway","root","ad
min");
Statement stmt=con.createStatement();
ResultSet rs=null;
if(choice==0)
con.close();
private void
deleteBTNActionPerformed(java.awt.event.ActionEvent evt) {
try{
Class.forName("java.sql.Driver");
Connection
con=DriverManager.getConnection("jdbc:mysql://localhost:3306/railway","root","ad
min");
Statement stmt=con.createStatement();
ResultSet rs=null;
59
if (choice==0)
con.close();
private void
jMenu4ActionPerformed(java.awt.event.ActionEvent evt) {
System.exit(0); // TODO add your handling code here:
private void
jMenuItem2ActionPerformed(java.awt.event.ActionEvent evt) {
new login().setVisible(true); // TODO add your handling code here:
this.dispose();
private void
jMenuItem3ActionPerformed(java.awt.event.ActionEvent evt) {
60
BIBLIOGRAPHY
61
RAILWAY
RESERVATION
SYSTEM
THE END
62