Latest Tutorials| Questions and Answers|Ask Questions?|Site Map




Have Programming Question? Ask it here!
 
 
 


Pradeep
seats
1 Answer(s)      4 years and 6 months ago
Posted in : JDBC


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 ?

Advertisement
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
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
Login) MBA,MCA,MCOM 5) Fees Structure 6) Available Seats and etc. plz Give Me
College Student Admission System Project in Java
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 - Java Beginners
) 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
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
About Eros Cimema Hall Jangpura Extension Delhi
seats in the back that offer more room and enjoyable amenities for people to use. The seats in this premium area are different from what is used elsewhere. The seats feature comfortable red leather fabric that is softer than what
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
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
help in uml - Java Beginners
,in terms of number of seats ,are recorded for each car. vehicles may be out
ARRAYS - Java Beginners
+" "+i); } System.out.println("All seats are reserved"); writeToFile
Cafe and Restaurant Website Design
of international foods and flavors, the prices of which do not suit every pocket. Seats
Meghalaya Tourist Places
Alliances Flights (50 seats) operate on this route that connects Shillong
Explore and enjoy the Lakshadweep Islands Tourism
conditioned hall with push back seats. Marine Wealth Awareness Programme:  
VoIP Providers
is focused on serving businesses with 5 to 500 seats. We don't knock on people's
MCA Project Training
the opportunity. There are only few seats vacant in the upcoming schedule. You just need
Tourist Places of Karnataka India
. Melkote Tour: One of the four seats of Ramanujam sect, Chellappilai
IT Training in India
the coming week. So, come and join the earliest as the seats are reserved with first
Open Source Groupware
as 25 million seats will still be on Exchange 5.5 at the beginning of next year
JSF Books
, the application ensures that the seats are available and marks them as reserved
 

 

 

DMCA.com