How to write program to show status of seats(i.e.free or reserve) in java?

Ads
 

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.

View Answers

May 2, 2012 at 1:27 PM

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 'seatbooking' 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`)
)

You can also visit the following link:

Assign Seats

Ads









Related Tutorials/Questions & Answers:
How to write program to show status of seats(i.e.free or reserve) in java?
Write a program that replaces a, e, i, o, u in Java2
Advertisements
How to write Java Program
how to write this program
Write a C/C++ program to show the result of a stored procedure
Java2
How to write calculator in J2ME program?
how to write servlet program in eclipse?
Assigning seats on an airplane
how to write a program to search a record using mvc2
how do i write a java program for this??
How to write a program count total prices
How to write a program count total prices
How to write hello world example program in Hibernate?
write a program
How to Write a Calculator Program in Java?
how can i write this program ?please suggest me
how to write to java program to get the particular data from the website
how to show effect (visual) on jsp page using value from database
Javah
how to write a program in java to print numbers in equalateral triangle
How do I write a program to manage an employee's business and personal contacts?
write a java program
Write a java application program........?
WRITE A PROGRAM IN JAVA
write the java program?
write the java program?
Write java program?
Write java program?
write a program to print
WRITE A PROGRAM IN JAVA

Ads