Hi,
I'd be very grateful if somebody could see where my syntax error is in my SQL statements.
thanx :-)
<html>
<head>
<title> Checkout</title>
</head>
<body bgcolor="#228B22">
<font face="Times New Roman,Times" size="+3"> Checkout</font>
<hr>
<
jsp:useBean id="cb" scope="session" class="myBeans.CartBean"/>
<form method=get>
<%
String notEntered = "";
String connectionURL ="jdbc:mysql://localhost:3306/petshopwebsite";
String driver= "com.mysql.jdbc.Driver";
Connection c = null;
ResultSet rs = null;
Statement st = null;
String password = "";
String username ="root";
try{
Class.forName("com.mysql.jdbc.Driver");
c = DriverManager.getConnection(connectionURL,username, password);
st = c.createStatement();
%>
<%
String Username = request.getParameter("username");
String productId = request.getParameter("productId");
String Quantity = request.getParameter("Quantity");
PreparedStatement p = c.prepareStatement("SELECT Username FROM customerdetails WHERE username='"+ Username +"'");
PreparedStatement p1 = c.prepareStatement("SELECT productId FROM product WHERE productId='"+ productId +"'");
PreparedStatement p2 = c.prepareStatement("INSERT INTO order (Username,productId,Quantity)VALUES('"+Username+"','"+productId+"','"+Quantity+"')");
p.execute();
p1.execute();
int affectedRows= p2.executeUpdate();
if (rs.next()){
Username = rs.getString(1);
System.out.println(Username);
productId = rs.getString(2);
System.out.println(productId);
Quantity = rs.getString(3);
System.out.println(Quantity);
%>
<jsp:include page = "signinsuccessful.jsp"/> <%--display this page on the current page--%>
<%
}
else{
%>
<jsp:include page = "Err.jsp"/> <%--display this page on the current page--%>
<%}
%>
<a href="http://localhost:3306/categoryList.jsp">Shop some more!</a>
<%
}
catch(Exception yu){
yu.printStackTrace();
}
finally
{
try { if( rs != null ) rs.close() ; } catch( SQLException ex ) { }
try { if( st != null ) st.close() ; } catch( SQLException ex ) { }
try { if( c != null ) c.close() ; } catch( SQLException ex ) { }
}
%>
</center>
</body>
</html>