seats

seats

i want a image and code of seat like, user should able to book a ticket online and he should able to see which seats has been booked and which seats is available and accordingly calculation should be done ?
View Answers

February 12, 2010 at 12:44 PM

Hi Friend,

Try the following code:

1)bookSeat.jsp:

<%@page import="java.sql.*"%>
<html>
<form method="post" action="Place.jsp">
<table border="1">
<tr><th>Sno</th><th>Comp A</th><th>Comp B</th><th>Comp C</th><th>Comp D</th></tr>
<%
Class.forName("com.mysql.jdbc.Driver");
Connection con=DriverManager.getConnection("jdbc:mysql://localhost:3306/register","root","root";);
Statement st=con.createStatement();
ResultSet rs= st.executeQuery("select * from seatbooking");
while(rs.next()){
%>
<tr><td><%=rs.getString(1)%></td><td><%=rs.getString(2)%></td><td><%=rs.getString(3)%></td><td><%=rs.getString(4)%></td><td><%=rs.getString(5)%></td><td></tr>

<%
}
%>
</table>
<table>
<tr><td>Enter Name:</td><td><input type="text" name="name"></td></tr>
<tr><td>Enter Seat to Reserve:</td><td><input type="text" name="seat"></td></tr>
<tr><td><input type="submit" value="Submit"></td></tr>
</table>
</form>
</html>

2)Place.jsp:
<%@page import="java.sql.*"%>
<%
String name=request.getParameter("name");
String seat=request.getParameter("seat");
char ch1=seat.charAt(0);
char ch2=seat.charAt(1);
Class.forName("com.mysql.jdbc.Driver");
Connection con=DriverManager.getConnection("jdbc:mysql://localhost:3306/register","root","root";);
Statement stmt=con.createStatement();
int i=stmt.executeUpdate("update seatbooking set code"+Character.toString(ch1)+"='booked' where no='"+Character.toString(ch2)+"'");
int j=stmt.executeUpdate("insert into seatinformation(name,seat) values('"+name+"','"+seat+"')");
response.sendRedirect("../jsp/bookSeat.jsp");
%>

For the above code, we have created 2 database tables 'seatbokking' and seatinformation:
CREATE TABLE `seatbooking` (
`no` bigint(255) NOT NULL auto_increment,
`codeA` varchar(255) default NULL,
`codeB` varchar(255) default NULL,
`codeC` varchar(255) default NULL,
`codeD` varchar(255) default NULL,
PRIMARY KEY (`no`)
)
CREATE TABLE `seatinformation` (
`id` bigint(255) NOT NULL auto_increment,
`name` varchar(255) default NULL,
`seat` varchar(255) default NULL,
PRIMARY KEY (`id`)
)

Hope that it will be helpful for you.
Thanks









Related Tutorials/Questions & Answers:
seats - JDBC
seats  i want a image and code of seat like, user should able to book a ticket online and he should able to see which seats has been booked and which seats is available and accordingly calculation should be done ?  Hi
Assigning seats on an airplane
Assigning seats on an airplane  Hi How to write a java program (using swing classes) to assign seats on an airplane .Assume the airplane has 20 seats in first class(5 rows of 4 seats each, seperated by an aisle), and 180 seats
Advertisements
How to write program to show status of seats(i.e.free or reserve) in java?
How to write program to show status of seats(i.e.free or reserve) in java?  I have retrieved data from database table and I want to display status of seats i.e.free or reserved
Assign Airline Seats to Passengers using Java
Assign Airline Seats to Passengers using Java Here we are going to create an application through which we can assign seats to passengers in an airplane... another seat no. This will continue until all seats are filled or until the user
Integrated Struts 2 Hibernate and JPA Training
week. So, come and join the earliest as the seats are reserved with first-come
OOP with Java-Array - Java Beginners
OOP with Java-Array  Write a program to assign passengers seats... the seats already assigned. For example, after seats 1A, 2B, and 4C are taken... 5 A B C D 6 A B C D 7 A B C D After displaying the seats
airline reservation - Java Beginners
airline reservation example  (Airline Reservation System) A small airline has just purchases a computer for its new automated reservations system. You have... seats on each flight of the airlines? only plane (capacity: 10 seats
how to show effect (visual) on jsp page using value from database
" I am thinking to use a map of seats ( with pictures controllers as seats) What... as seats should be displayed red. when the value in booking status... multiple seats , Please help
Checkbox blocked - WebSevices
Checkbox blocked  Hi, i design online ticket reservation for bus. It contains no of seats. if i choose 3 or 4 seats checkbox,it will stored in my database. After i refreshing the page that checkbox seats are blocked
Java Arrary - Java Beginners
Java Arrary  Use an array to represent the seating chart of the plane. Initialize all the elements of the array to 0 to indicate that all seats are empty. As each seat is assigned, set the corresponding elements of the array
C Programming
C Programming  hi,how can i write a program in C programming to place reservation in air plane from the menu let the user to inter his/her gender(W or M)and draw seats by using ascii codes and choose where he/she will sit
java code
have multiple category of seats operations to be performed: 1)Book tickets for movie A(silver-Rs.100,gold-Rs.150,plantinum-Rs.200).show available seats before
Array
Array  Write an application to assign seats on the cinema theater?s only showroom (capacity: 10 seats). Your application should display.... It should also display the total number of Twin Seats and Normal Seats
OOP with Java - Java Beginners
the question. Write a program to assign passengers seats in an airplane... display the seat pattern, with an 'X' marking the seats already assigned. For example, after seats 1A, 2B, and 4C are taken, the display should look like: 1 X
airline reservation java code - Java Beginners
the booking of seats on board a small airplane. The layout of the aircraft... reset the bookings and free up ALL seats once again. Things to consider : Smoking or Non-Smoking: Seats in rows 5,6,7 and 8 are designated as smoking seats
reg : the want of source code
) Available Seats and etc. plz Give Me Full Source code with Database
College Student Admission System Project in Java - Development process
) Fees Structure 6) Available Seats and etc. plz Give Me Full Source code
College Student Admission System Project in Java - Java Beginners
) Available Seats and etc. plz Give Me Full Source code with Database
College Student Admission System Project in Java - Java Beginners
) Available Seats and etc. plz Give Me Full Source code with Database
College Student Admission System Project in Java
Seats and etc. plz Give Me Full Source code with Database
college student admission
Login) MBA,MCA,MCOM 5) Fees Structure 6) Available Seats and etc. plz Give Me
12 Seater Tempo Traveller on rent in Delhi to Rishikesh
Traveller with AC and Pushback seats Planning to travel to Rishikesh from Delhi... and Pushback seats for traveling to Rishikesh at very attractive price. We... seats - Rs, 16 per KM Tempo Traveler with 16 seats - Rs. 19 per KM
Admission Validation - Java Beginners
Form ,I want to Display Admission Status on Form that is Availbal Seats and Fillup Seats and when I FillUp 60 students in Access Databse I want to Show Status..., you will come to know about the filled seats. If seats exceed 60, then display
Problem Statement : Show Booking System
are intrested in. int noOfSeats - Number of seats you want to book. It should
About Eros Cinema Hall Jangpura Extension Delhi
of the area. There are also some premium seats in the back that offer more room and enjoyable amenities for people to use.ADS_TO_REPLACE_3 The seats in this premium area are different from what is used elsewhere. The seats feature comfortable
Eclipse - Java Beginners
;i  Hi, thanks for helping me in the code but I got some seats are already taken. So how do I modify the code such that some of the seats are already
java netbean - UML
, the airline runs only one aircraft with a capacity of 10 seats and has three types... section. The system should be able to assign seats on each flight of the airline¡¦s
ARRAYS - Java Beginners
+" "+i); } System.out.println("All seats are reserved"); writeToFile
help in uml - Java Beginners
,in terms of number of seats ,are recorded for each car. vehicles may be out
Cricket stadium ticket booking design
Cricket stadium ticket booking design  How can I design a pictorial representation for the booked and available seats in the stadium showing graphically the booked tickets as of red color and available ticket as green color
Cafe and Restaurant Website Design
pocket. Seats are also booked in advance often at such places. Visiting
Cost of Tempo Traveller from Delhi to Rishikesh
Traveller is very luxurious vehicle with ample space and push back seats. In Tempo
Meghalaya Tourist Places
Alliances Flights (50 seats) operate on this route that connects Shillong
MCA Project Training
the opportunity. There are only few seats vacant in the upcoming schedule. You just need
VoIP Providers
is focused on serving businesses with 5 to 500 seats. We don't knock on people's
Explore and enjoy the Lakshadweep Islands Tourism
Class: Air conditioned hall with push back seats. Marine Wealth Awareness
Tourist Places of Karnataka India
_TO_REPLACE_15 Melkote Tour: One of the four seats of Ramanujam sect, Chellappilai
Open Source Groupware
as 25 million seats will still be on Exchange 5.5 at the beginning of next year
IT Training in India
the coming week. So, come and join the earliest as the seats are reserved
JSF Books
, the application ensures that the seats are available and marks them as reserved

Ads