- Java Program For Train Reservation Details
- Railway Reservation Pnr
- Welcome To Indian Railways Reservation
- Java Programs On Arrays
- Java Programs On Strings
SQL- RAILWAY RESERVATION SYSTEM [SOLVED] Could not open jvm.cfg; SQL- LIBRARY MANAGEMENT SYSTEM; Java - Blowfish Encryption Algorithm; Write a program in C to perform token separation; Aptitude Questions Set No 2. How we write a Java program on railway reservation system using files? Update Cancel. A d b y D a t a d o g H Q. Write a Java program using files on railway reservation sytsem? Not use any database simple program we can run in cmd. Write a Java program using files on railway reservation sytsem? Not use any database simple program we can. Displaying search result for: java program for online ticket reservation ticket reservation ticket reservation sir i need a java program for the airway online ticket resrvation using swings in java as frontend and mysql as backend. Sir ur program will be very help full for our project how to prepare railway reservation form using core java.
I am new to Java and was trying to understand how synchronizatioon works. So I created a Plane Reservation System and I am able to simulate mutliple users trying to make a reservation and use Synchromization to get the correct output.
Now that it works, I am thinking how this works in the real world. For instance, let us say the application is built on Swing and this is a multi user application. For simplicity let us assume there are only two planes 'AAA' and 'BBB'. This application may be installed in each of the ticket counter agent's computer , the kiosks at the airport and as well as in the computers of different travel agents and all of them accessing the same database.
In this case, each user/computer will have its own instance of Reserve class, Transaction class and Plane class. So there is only one thread/request in the Transaction class and there is no synchronization.
My question is, how will a mutli user application like this Reservation system actually be designed/implemeneted such that all users are accessing one instance of Transacion class so that synchronization can happen. You can also look at this question as, how can I build a mutli-user game played by different players across different computers. One more example would be a Banking system to make deposits, withdrawals and transfers when the application is running in the ATM as well as the Teller's machine.
///////////////////////////////
Reserve.java ---> Point of entry for each request made by a user
/////////////////////////////
///////////////////////////////
Transaction.java ---> Actual transaction happens here
/////////////////////////////
///////////////////////////////
Plane.java ---> Information about the plane
/////////////////////////////
///////////////////////////////
Seats.java ---> To simulate each time a request is made by the user the 'number of availabe seats' is retrieved from a common datasource/db./////////////////////////////
user547453user5474532 Answers
Symplistically, you'd make all Transaction
s methods synchronized
: this would give you mutual exclusion.
In reality, however, no system is designed like that. The server-side application is not modelled as a single synchronized object. Rather, the durable state is maintained in a relational database that supports ACID transactions (atomic, concurrent, isolated, and durable) and the equivalent of the Transaction
object is a stateless singleton object that needs no synchronization on Java level. Such an object would be called a service bean. It would typically be created within a Dependency Injection container, such as Spring, and it would be connected to a bunch of other objects, such as DAOs (Data Access Object), which would in turn implement the low-level logic of interaction with a database. The Dependency Injection container makes it easy to declaratively build a complex graph of interconnected objects. A typical enterprise application, such as an airline's reservation system, contains at least tens of service beans and even more DAOs, which connect to a variety of back-end systems.
Either
a) you rely in the database stored procedures (that ensure atomicity) to perform the operation.
b) you only have one instance (a server) that holds the critical section. The clients perform request to it, the server tells if there were seats available (operation succeeded) or there weren't (opertion failed).
Java Program For Train Reservation Details
Real world operative will be mostly b, which can use a.
SJuan76SJuan76Railway Reservation Pnr
Welcome To Indian Railways Reservation
Not the answer you're looking for? Browse other questions tagged javamultithreadingsynchronization or ask your own question.
PermalinkJoin GitHub today
Java Programs On Arrays
GitHub is home to over 40 million developers working together to host and review code, manage projects, and build software together.
Sign up1 contributor
/* |
* ViewAllTrains.java |
* Created on Jul 26, 2011, 12:34:59 AM |
*/ |
packageibmProject.railwayReservation; |
importjava.sql.*; |
importjavax.swing.*; |
/**@author Dip*/ |
/** |
* This class creates a new frame called View All Trains which opens a new window |
* showing all the trains which exist in the railways train database. |
*/ |
publicclassViewAllTrainsextendsJFrame { |
/** The constructor of the ViewAllTrains class */ |
publicViewAllTrains() { |
initComponents(); |
} |
Connection con; |
/** This method connects to the MS ACCESS database using a Type-I JDBC driver. */ |
publicvoidconnect() { |
try { |
Class.forName('sun.jdbc.odbc.JdbcOdbcDriver'); |
con =DriverManager.getConnection('jdbc:odbc:Railwaydb'); |
} catch (Exception e) { |
System.err.println('Error : '+ e); |
} |
} |
/** |
* This method retrieves all the necessary train details from the database and |
* then it stored them in a matrix and displays the output in a table format. |
*/ |
publicvoidviewTrains() { |
int n =0; |
double dist =0; |
String name =null, dep =null, arr =null, arrtime =null, deptime =null; |
String title[] =newString[]{ |
'Train number', 'Train name', 'Departing Station', 'Arriving Station', 'Departure time', 'Arrival time', 'Total distance' |
}; |
try { |
Statement st; |
ResultSet rs =null; |
st = con.createStatement(); |
rs = st.executeQuery('select * from train'); |
int i =0; |
Object[][] data =newObject[8][8]; |
while (rs.next()) { |
n = rs.getInt(1); |
name = rs.getString(2); |
dep = rs.getString(3); |
arr = rs.getString(4); |
arrtime = rs.getTime(5).toString(); |
deptime = rs.getTime(6).toString(); |
dist = rs.getFloat(7); |
data[i][0] = n; |
data[i][1] = name; |
data[i][2] = dep; |
data[i][3] = arr; |
data[i][4] = arrtime; |
data[i][5] = deptime; |
data[i][6] = dist; |
i +=1; |
} |
jTable1.setModel(newjavax.swing.table.DefaultTableModel(data, title)); |
st.close(); |
con.close(); |
} catch (SQLException e) { |
JOptionPane.showMessageDialog(null, 'Error in retrieving data'); |
} |
} |
/** This method is called from within the constructor to |
* initialize the form. |
* WARNING: Do NOT modify this code. The content of this method is |
* always regenerated by the Form Editor. |
*/ |
@SuppressWarnings('unchecked') |
// <editor-fold defaultstate='collapsed' desc='Generated Code'>//GEN-BEGIN:initComponents |
privatevoidinitComponents() { |
jScrollPane1 =newjavax.swing.JScrollPane(); |
jTable1 =newjavax.swing.JTable(); |
jLabel1 =newjavax.swing.JLabel(); |
jLabel2 =newjavax.swing.JLabel(); |
jLabel3 =newjavax.swing.JLabel(); |
setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE); |
setResizable(false); |
jTable1.setFont(newjava.awt.Font('Tahoma', 1, 11)); |
jTable1.setModel(newjavax.swing.table.DefaultTableModel( |
newObject [][] { |
{null, null, null, null}, |
{null, null, null, null}, |
{null, null, null, null}, |
{null, null, null, null} |
}, |
newString [] { |
'Title 1', 'Title 2', 'Title 3', 'Title 4' |
} |
)); |
jTable1.setEnabled(false); |
jTable1.setShowHorizontalLines(false); |
jScrollPane1.setViewportView(jTable1); |
jLabel1.setBackground(newjava.awt.Color(51, 51, 51)); |
jLabel1.setFont(newjava.awt.Font('Nyala', 1, 36)); |
jLabel1.setHorizontalAlignment(javax.swing.SwingConstants.CENTER); |
jLabel1.setText('LIST OF ALL THE TRAINS RUNNING'); |
jLabel1.setBorder(javax.swing.BorderFactory.createCompoundBorder(newjavax.swing.border.LineBorder(newjava.awt.Color(0, 0, 0), 1, true), javax.swing.BorderFactory.createEtchedBorder(javax.swing.border.EtchedBorder.RAISED))); |
jLabel2.setIcon(newjavax.swing.ImageIcon(getClass().getResource('/ibmProject/railwayReservation/imgs/logo2.jpg'))); // NOI18N |
jLabel3.setIcon(newjavax.swing.ImageIcon(getClass().getResource('/ibmProject/railwayReservation/imgs/logo2.jpg'))); // NOI18N |
javax.swing.GroupLayout layout =newjavax.swing.GroupLayout(getContentPane()); |
getContentPane().setLayout(layout); |
layout.setHorizontalGroup( |
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) |
.addGroup(layout.createSequentialGroup() |
.addContainerGap() |
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) |
.addGroup(layout.createSequentialGroup() |
.addComponent(jLabel2) |
.addGap(123, 123, 123) |
.addComponent(jLabel1, javax.swing.GroupLayout.PREFERRED_SIZE, 580, javax.swing.GroupLayout.PREFERRED_SIZE) |
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 126, Short.MAX_VALUE) |
.addComponent(jLabel3)) |
.addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 1029, Short.MAX_VALUE)) |
.addContainerGap()) |
); |
layout.setVerticalGroup( |
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) |
.addGroup(layout.createSequentialGroup() |
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) |
.addGroup(layout.createSequentialGroup() |
.addContainerGap() |
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) |
.addComponent(jLabel2) |
.addComponent(jLabel3))) |
.addGroup(layout.createSequentialGroup() |
.addGap(32, 32, 32) |
.addComponent(jLabel1, javax.swing.GroupLayout.PREFERRED_SIZE, 65, javax.swing.GroupLayout.PREFERRED_SIZE))) |
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 43, Short.MAX_VALUE) |
.addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 204, javax.swing.GroupLayout.PREFERRED_SIZE) |
.addGap(45, 45, 45)) |
); |
pack(); |
}// </editor-fold>//GEN-END:initComponents |
/** The main method from where execution of the program begins. */ |
publicstaticvoidmain(Stringargs[]) { |
java.awt.EventQueue.invokeLater(newRunnable() { |
ViewAllTrains vt =newViewAllTrains(); |
publicvoidrun() { |
vt.setVisible(true); |
vt.connect(); |
vt.viewTrains(); |
} |
}); |
} |
// Variables declaration - do not modify//GEN-BEGIN:variables |
privatejavax.swing.JLabel jLabel1; |
privatejavax.swing.JLabel jLabel2; |
privatejavax.swing.JLabel jLabel3; |
privatejavax.swing.JScrollPane jScrollPane1; |
publicjavax.swing.JTable jTable1; |
// End of variables declaration//GEN-END:variables |
} |
Java Programs On Strings
Copy lines Copy permalink