hai any one can help regarding this.
iam involved in e-ticketing project..
iam going to retrieve ticket values from database to
jsp page. Now i want to book the ticket so i will select the ticket using checkbox..the selected ticket value should be insert into mysql db..i tried to insert but its not inserting can anyone help me..
my code is here below :
<%@ page import="java.sql.*" %>
<%@ page import="java.io.*" %>�
<html>
<head>
<title>display data from the table using jsp</title>
</head>
<body>
<h2 align="center"></h2>
<select id="cbosex" name="cbosex">
<option value="true">Male</option>
<option value="false">Female</option>
</option>
<%
try {
Connection con = null;
Statement st= null;
ResultSet rs = null;
Class.forName("org.gjt.mm.mysql.Driver");
con=DriverManager.getConnection("jdbc:mysql://192.168.1.201:3306/e_busticketing","root","password");
st = con.createStatement();
out.println("connected");
String sql="select seat_no from e_busticketing.seat_mast where bus_id=1001";
rs=st.executeQuery(sql);
%>
<TABLE cellpadding="15" border="1" style="background-color: #ffffcc;" width=20% align="center">
<%
while (rs.next()) {
%>
<TR>
<TD><INPUT TYPE=CHECKBOX NAME=c1 value=<%=rs.getString("seat_no")%> ></TD>
</TR>
<% } %>
<%
// close all the connections.
rs.close();
st.close();
con.close();
}
catch (Exception ex)
{
%>
</font>
<font size="+3" color="red"></b>
<%
out.println("Unable to connect to database.");
}
%>
</TABLE><TABLE align="center">
<TR>
<TD><FORM ACTION="busdetail.jsp" method="get" >
<button type="submit"><-- back</button></TD>
</TR>
</TABLE>
</font>
<%
/*
try
{
Class.forName("org.gjt.mm.mysql.Driver");
con=DriverManager.getConnection("jdbc:mysql://192.168.1.201:3306/e_busticketing","root","password");
out.println("connected sucessfully");
Statement st = con.createStatement();
int numRowsChanged = st.executeUpdate("insert into e_busticketing.seat_details(seat) values (c1)";
out.println("data inserted");
}
catch (Exception e)
{
e.printStackTrace();
}
}
}
*/
%>
</body>
</html>
regards
gopi
[ November 11, 2008: Message edited by: Bear Bibeault ]