Académique Documents
Professionnel Documents
Culture Documents
entitled
RAILWAY RESERVATION SYSTEM
not been submitted for any other examination and does not
candidate.
ROLL NO:
GUIDED BY
Mr. A.K. Pandey
(Head of Computer
Dept.)
2
3
u
ACKNOWLEDGEMENT
ndertook 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.
4
help me with valuable suggestions in the successful
completion of this project.
5
C O N T E N T S
1. Introduction------------------------------------------5
2. Theoretical Background-----------------------------6
3. System Implementation-------------------------15
5.Bibliography ----------------------------------------61
6
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
7
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.
8
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.
9
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.
INT RODUCTION
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
language choice of Internet and Intranet applications.
Java plays an important role for the proper functioning
of many software-based devices attached to
11
network.The kind of functionality the Java offers, has
contributed a lot towards the popularity of Java.
BYTE CODE
12
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.
*******
13
MySQL SERVER 5.1
(BACK END SOFTWARE)
INT RODUCTION
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.
15
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
16
3. System Im pl eme nt at io n
17
TABLE STRUCTURE
LOGIN DETAILS
SAMPLE DATA
18
INFO TABLE
SAMPLE DATA
19
RECORD TABLE
SAMPLE DATA
20
(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{
21
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.getStrin
g("uname")))
{new intro().setVisible(true);
this.dispose();}
else
System.out.print("wrong"); }
con.close();
private void
manageAccBTNActionPerformed(java.awt.event.ActionEve
nt evt) {
new manageAcc().setVisible(true);
22
private void
jMenu4ActionPerformed(java.awt.event.ActionEvent evt) {
private void
jMenuItem3ActionPerformed(java.awt.event.ActionEvent
evt) {
System.exit(0); // TODO add your handling code here:
23
(2) START PAGE
CODING:
private void
jButton1ActionPerformed(java.awt.event.ActionEvent evt)
{
this.dispose();
24
(3) LOADING PAGE
CODING:
private void
goBTNActionPerformed(java.awt.event.ActionEvent evt) {
new homescreen().setVisible(true);
25
(4) HOME SCREEN
CODING:
private void
exitMIActionPerformed(java.awt.event.ActionEvent evt) {
private void
jMenu4ActionPerformed(java.awt.event.ActionEvent evt) {
private void
bookTicketMIActionPerformed(java.awt.event.ActionEvent
evt) {
26
this.dispose();
private void
CancelTicketMIActionPerformed(java.awt.event.Act
ionEvent evt) {
this.dispose();
private void
DisplayRecordsMIActionPerformed(java.awt.event.ActionE
vent evt) {
this.dispose();
private void
addTrianInfoMIActionPerformed(java.awt.event.ActionEve
nt evt) {
this.dispose();
27
private void
checkTrainInfoMIActionPerformed(java.awt.event.ActionEv
ent 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.ActionEve
nt evt) {
this.dispose();
28
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);
if (boardRB.getSelectedIndex()==destinationRB.getSelectedIndex() ||
(monthRB.getSelectedIndex()==0)||yearRB.getSelectedIndex()==0||
dayRB.getSelectedIndex()==0)
29
JOptionPane.showMessageDialog(null,"PLEASE CHOOSE DESTINATION or DATE
CORRECTLY");
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);
*/
30
// TODO add your handling code here:
private void
netAmountBTNActionPerformed(java.awt.event.ActionEve
nt 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)
{
String date=(""+year+"-"+month+"-"+day+"");
31
String train=(String) trainRB.getSelectedItem();
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++){
try{
32
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);
33
private void
bookTicketMIActionPerformed(java.awt.event.ActionEvent
evt) {
this.dispose();
private void
CancelTicketMIActionPerformed(java.awt.event.ActionEve
nt evt) {
this.dispose();
private void
DisplayRecordsMIActionPerformed(java.awt.event.ActionEvent evt)
{
this.dispose();
private void
addTrianInfoMIActionPerformed(java.awt.event.ActionEve
nt evt) {
this.dispose();
34
private void
checkTrainInfoMIActionPerformed(java.awt.event.ActionEv
ent 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.ActionEve
nt evt) {
this.dispose();
private void
exitMIActionPerformed(java.awt.event.ActionEvent evt) {
System.exit(0); // TODO add your handling code here:
35
private void
jMenu4ActionPerformed(java.awt.event.ActionEvent evt) {
36
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) {
PNR=Integer.parseInt(JOptionPane.showInputDialog("ENTER YOUR PNR
NUMBER")); // TODO add your handling code here:
37
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);
while (rs.next()) {
38
String psex = rs.getString("Psex");
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);
private void
jButton1ActionPerformed(java.awt.event.ActionEvent evt)
{
39
int choice = JOptionPane.showConfirmDialog(null,"ARE YOU SURE THAT YOU WANT
TO CANCEL THE TICKET");
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();
private void
CancelTicketMIActionPerformed(java.awt.event.ActionEve
nt evt) {
this.dispose();
40
new cancelTicket().setVisible(true); // TODO add your handling code here:
private void
DisplayRecordsMIActionPerformed(java.awt.event.ActionE
vent evt) {
this.dispose();
private void
addTrianInfoMIActionPerformed(java.awt.event.ActionEve
nt evt) {
this.dispose();
private void
checkTrainInfoMIActionPerformed(java.awt.event.ActionEv
ent evt) {
this.dispose();
private void
SignOutMIActionPerformed(java.awt.event.ActionEvent
evt) {
41
// TODO add your handling code here:
this.dispose();
private void
homeScreenMIActionPerformed(java.awt.event.ActionEve
nt 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) {
42
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) {
DefaultTableModel model = (DefaultTableModel) recordTBL.getModel();
43
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){
try {
Class.forName("com.mysql.jdbc.Driver").newInstance();
44
Connection con = (Connection)
DriverManager.getConnection("jdbc:mysql://localhost:3306/railway","root","admin");
ResultSet rs = stmt.executeQuery(query);
while (rs.next()) {
} catch (Exception e) {
JOptionPane.showMessageDialog(this, e.getMessage());
} } else
private void
bookTicketMI5ActionPerformed(java.awt.event.ActionEven
t evt) {
this.dispose();
45
new bookticket().setVisible(true); // TODO add your handling code here:
private void
CancelTicketMIActionPerformed(java.awt.event.ActionEve
nt evt) {
this.dispose();
private void
DisplayRecordsMIActionPerformed(java.awt.event.ActionE
vent evt) {
this.dispose();
private void
addTrianInfoMIActionPerformed(java.awt.event.ActionEve
nt evt) {
this.dispose();
private void
checkTrainInfoMIActionPerformed(java.awt.event.ActionEv
ent evt) {
46
this.dispose();
private void
SignOutMIActionPerformed(java.awt.event.ActionEvent
evt) {
// TODO add your handling code here:
this.dispose();
private void
homeScreenMIActionPerformed(java.awt.event.ActionEve
nt evt) {
this.dispose();
private void
exitMIActionPerformed(java.awt.event.ActionEvent evt) {
private void
jMenu10ActionPerformed(java.awt.event.ActionEvent evt)
{
47
System.exit(0); // TODO add your handling code here:
48
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.ActionE
vent evt) {
String tname =(String) trainRB.getSelectedItem();
try {
49
// Connect to MySQL database
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());
50
private void
bookTicketMIActionPerformed(java.awt.event.ActionEvent
evt) {
this.dispose();
private void
CancelTicketMIActionPerformed(java.awt.event.ActionEve
nt evt) {
this.dispose();
private void
DisplayRecordsMIActionPerformed(java.awt.event.ActionE
vent evt) {
this.dispose();
private void
addTrianInfoMIActionPerformed(java.awt.event.ActionEve
nt evt) {
this.dispose();
51
private void
checkTrainInfoMIActionPerformed(java.awt.event.ActionEv
ent 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.ActionEve
nt evt) {
this.dispose();
private void
exitMIActionPerformed(java.awt.event.ActionEvent evt) {
52
private void
jMenu4ActionPerformed(java.awt.event.ActionEvent evt) {
System.exit(0); // TODO add your handling code here:
53
(9) ADD TRAIN INFO
IMPORT COMMAND:
import java.sql.*;
import javax.swing.JOptionPane;
CODING:
private void
Get_train_infoBTNActionPerformed(java.awt.event.ActionE
vent evt) {
54
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());
55
}
private void
bookTicketMIActionPerformed(java.awt.event.ActionEvent
evt) {
this.dispose();
private void
CancelTicketMIActionPerformed(java.awt.event.ActionEve
nt evt) {
this.dispose();
private void
DisplayRecordsMIActionPerformed(java.awt.event.ActionE
vent evt) {
this.dispose();
private void
addTrianInfoMIActionPerformed(java.awt.event.ActionEve
nt evt) {
this.dispose();
56
new addTrainInfo().setVisible(true); // TODO add your handling code here:
private void
checkTrainInfoMIActionPerformed(java.awt.event.ActionEv
ent 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.ActionEve
nt evt) {
this.dispose();
private void
exitMIActionPerformed(java.awt.event.ActionEvent evt) {
57
System.exit(0); // TODO add your handling code here:
private void
jMenu4ActionPerformed(java.awt.event.ActionEvent evt) {
System.exit(0); // TODO add your handling code here:
58
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) {
String uname=nameTF.getText();int newAcc;
try{
Class.forName("java.sql.Driver");
59
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) {
String uname=nameTF.getText();int delAcc;
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)
60
delAcc = stmt.executeUpdate("delete from login where uname
='"+uname+"' and pass ='"+pass+"';");
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) {
System.exit(0); // TODO add your handling code here: }
61
BIBLIOGRAPHY
62
RAILWAY
RESERVATION
SYSTEM
THE END
63
64