Can one of you bright sparks help me out. Connecting to MS Access database and have problems with connection using JSP. This is the code, errors follow:
<%@ page language="java" contentType="text/html"
import="ShoppingBasket,Product,java.util.*"
errorPage="errorpage.jsp"%>
<jsp:useBean id="basket" class="ShoppingBasket" scope="session"/>
<html>
<head>
<title>Your Order Has Been Received</title>
</head>
<body>
<%
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver"
java.sql.Connection connection = java.sql.DriverManager.getConnection("jdbcdbc:Novbase","",""
String query = "INSERT INTO Customer VALUES ('',?,?,?,?,?,?,?,?,?,?,?)";
java.sql.PreparedStatement Stmt = connection.prepareStatement(query);
Stmt.setString(1,request.getParameter("title");
Stmt.setString(2,request.getParameter("surname");
Stmt.setString(3,request.getParameter("firstname");
Stmt.setString(4,request.getParameter("address");
Stmt.setString(5,request.getParameter("address2");
Stmt.setString(6,request.getParameter("town");
Stmt.setString(7,request.getParameter("postcode");
Stmt.setString(8,request.getParameter("email");
Stmt.setString(9,request.getParameter("password");
Stmt.setString(10,request.getParameter("dob");
Stmt.setString(11,request.getParameter("tel_no");
Stmt.executeUpdate(query);
long customer_id = ((sun.jdbc.odbc.JdbcOdbcDriver)Stmt).getLastInsertID();
String query2 ="INSERT INTO Order VALUES ('','',?,?,'')";
java.sql.PreparedStatement Stmt2 = connection.PrepareStatement(query2);
Stmt2.setLong(1, customer_id);
Stmt2.setString(2, request.getParameter("total_value");
Stmt2.executeUpdate(query2);
long order_id = ((sun.jdbc.odbc.JdbcOdbcDriver)Stmt).getLastInsertID();
String query3 ="INSERT INTO OrderDetail VALUES ('',?,?,?)";
Enumeration products = basket.getProducts();
while(products.hasMoreElements())
{
Product product = (Product)products.nextElement();
Stmt3 = connection.prepareStatement(query3);
Stmt3.setLong(1,order_id);
Stmt3.setInt(2,Integer.parseInt(product.getId()));
Stmt3.setInt(3,product.getQuantity());
Stmt3.executeUpdate();
}
String query4="INSERT INTO Payment VALUES ('',?,?,?,?,?,?)";
java.sql.PreparedStatement Stmt4 = connection.PrepareStatement(query4);
Stmt4.setLong(1,order_id);
Stmt4.setString(2, request.getParameter("card_type");
Stmt4.setString(3, request.getParameter("card_number");
Stmt4.setString(4, request.getParameter("issue_no");
Stmt4.setString(5, request.getParameter("valid_from");
Stmt4.setString(6, request.getParameter("valid_to");
Stmt4.executeUpdate(query4);
Stmt.close();
Stmt2.close();
Stmt3.close();
Stmt4.close();
connection.close();
basket.emptyBasket();
%>
Thanks for your order. It will be processed within 24 hours.
Please note that your Order Number is No: <%= order_id %>
<br/><br/>
<a href=" <%= response.encodeURL("shop-products.jsp" %> ">
<img src="images\toshop.gif" border="0" alt="Return to the Shop"></a>
</body>
</html>
These are the errors I get:
org.apache.jasper.JasperException: Unable to compile class for JSPNote: sun.tools.javac.Main has been deprecated.
An error occurred between lines: 13 and 77 in the jsp file: /Novum/shop-postorder.jsp
Generated servlet error:
C:\Tomcat\jakarta-tomcat-4.0.4\work\Standalone\localhost\_\Novum\shop_0002dpostorder$jsp.java:111: Method getLastInsertID() not found in class sun.jdbc.odbc.JdbcOdbcDriver.
long customer_id = ((sun.jdbc.odbc.JdbcOdbcDriver)Stmt).getLastInsertID();
^
An error occurred between lines: 13 and 77 in the jsp file: /Novum/shop-postorder.jsp
Generated servlet error:
C:\Tomcat\jakarta-tomcat-4.0.4\work\Standalone\localhost\_\Novum\shop_0002dpostorder$jsp.java:114: Method PrepareStatement(java.lang.String) not found in interface java.sql.Connection.
java.sql.PreparedStatement Stmt2 = connection.PrepareStatement(query2);
^
An error occurred between lines: 13 and 77 in the jsp file: /Novum/shop-postorder.jsp
Generated servlet error:
C:\Tomcat\jakarta-tomcat-4.0.4\work\Standalone\localhost\_\Novum\shop_0002dpostorder$jsp.java:121: Method getLastInsertID() not found in class sun.jdbc.odbc.JdbcOdbcDriver.
long order_id = ((sun.jdbc.odbc.JdbcOdbcDriver)Stmt).getLastInsertID();
^
An error occurred between lines: 13 and 77 in the jsp file: /Novum/shop-postorder.jsp
Generated servlet error:
C:\Tomcat\jakarta-tomcat-4.0.4\work\Standalone\localhost\_\Novum\shop_0002dpostorder$jsp.java:129: Undefined variable: Stmt3
Stmt3 = connection.prepareStatement(query3);
^
An error occurred between lines: 13 and 77 in the jsp file: /Novum/shop-postorder.jsp
Generated servlet error:
C:\Tomcat\jakarta-tomcat-4.0.4\work\Standalone\localhost\_\Novum\shop_0002dpostorder$jsp.java:130: Undefined variable or class name: Stmt3
Stmt3.setLong(1,order_id);
^
An error occurred between lines: 13 and 77 in the jsp file: /Novum/shop-postorder.jsp
Generated servlet error:
C:\Tomcat\jakarta-tomcat-4.0.4\work\Standalone\localhost\_\Novum\shop_0002dpostorder$jsp.java:131: Undefined variable or class name: Stmt3
Stmt3.setInt(2,Integer.parseInt(product.getId()));
^
An error occurred between lines: 13 and 77 in the jsp file: /Novum/shop-postorder.jsp
Generated servlet error:
C:\Tomcat\jakarta-tomcat-4.0.4\work\Standalone\localhost\_\Novum\shop_0002dpostorder$jsp.java:132: Undefined variable or class name: Stmt3
Stmt3.setInt(3,product.getQuantity());
^
An error occurred between lines: 13 and 77 in the jsp file: /Novum/shop-postorder.jsp
Generated servlet error:
C:\Tomcat\jakarta-tomcat-4.0.4\work\Standalone\localhost\_\Novum\shop_0002dpostorder$jsp.java:133: Undefined variable or class name: Stmt3
Stmt3.executeUpdate();
^
An error occurred between lines: 13 and 77 in the jsp file: /Novum/shop-postorder.jsp
Generated servlet error:
C:\Tomcat\jakarta-tomcat-4.0.4\work\Standalone\localhost\_\Novum\shop_0002dpostorder$jsp.java:137: Method PrepareStatement(java.lang.String) not found in interface java.sql.Connection.
java.sql.PreparedStatement Stmt4 = connection.PrepareStatement(query4);
^
An error occurred between lines: 13 and 77 in the jsp file: /Novum/shop-postorder.jsp
Generated servlet error:
C:\Tomcat\jakarta-tomcat-4.0.4\work\Standalone\localhost\_\Novum\shop_0002dpostorder$jsp.java:150: Undefined variable or class name: Stmt3
Stmt3.close();
^
10 errors, 1 warning
at org.apache.jasper.compiler.Compiler.compile(Compiler.java:285)
at org.apache.jasper.servlet.JspServlet.loadJSP(JspServlet.java:548)
at org.apache.jasper.servlet.JspServlet$JspServletWrapper.loadIfNecessary(JspServlet.java:176)
at org.apache.jasper.servlet.JspServlet$JspServletWrapper.service(JspServlet.java:188)
at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:381)
at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:473)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:247)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:193)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:243)
at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:566)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:472)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:943)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:190)
at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:566)
at org.apache.catalina.valves.CertificatesValve.invoke(CertificatesValve.java:246)
at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:564)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:472)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:943)
at org.apache.catalina.core.StandardContext.invoke(StandardContext.java:2347)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:180)
at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:566)
at org.apache.catalina.valves.ErrorDispatcherValve.invoke(ErrorDispatcherValve.java:170)
at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:564)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:170)
at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:564)
at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:468)
at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:564)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:472)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:943)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:174)
at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:566)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:472)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:943)
at org.apache.catalina.connector.http.HttpProcessor.process(HttpProcessor.java:1027)
at org.apache.catalina.connector.http.HttpProcessor.run(HttpProcessor.java:1125)
at java.lang.Thread.run(Thread.java:536)
<%@ page language="java" contentType="text/html"
import="ShoppingBasket,Product,java.util.*"
errorPage="errorpage.jsp"%>
<jsp:useBean id="basket" class="ShoppingBasket" scope="session"/>
<html>
<head>
<title>Your Order Has Been Received</title>
</head>
<body>
<%
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver"
java.sql.Connection connection = java.sql.DriverManager.getConnection("jdbcdbc:Novbase","",""
String query = "INSERT INTO Customer VALUES ('',?,?,?,?,?,?,?,?,?,?,?)";
java.sql.PreparedStatement Stmt = connection.prepareStatement(query);
Stmt.setString(1,request.getParameter("title");
Stmt.setString(2,request.getParameter("surname");
Stmt.setString(3,request.getParameter("firstname");
Stmt.setString(4,request.getParameter("address");
Stmt.setString(5,request.getParameter("address2");
Stmt.setString(6,request.getParameter("town");
Stmt.setString(7,request.getParameter("postcode");
Stmt.setString(8,request.getParameter("email");
Stmt.setString(9,request.getParameter("password");
Stmt.setString(10,request.getParameter("dob");
Stmt.setString(11,request.getParameter("tel_no");
Stmt.executeUpdate(query);
long customer_id = ((sun.jdbc.odbc.JdbcOdbcDriver)Stmt).getLastInsertID();
String query2 ="INSERT INTO Order VALUES ('','',?,?,'')";
java.sql.PreparedStatement Stmt2 = connection.PrepareStatement(query2);
Stmt2.setLong(1, customer_id);
Stmt2.setString(2, request.getParameter("total_value");
Stmt2.executeUpdate(query2);
long order_id = ((sun.jdbc.odbc.JdbcOdbcDriver)Stmt).getLastInsertID();
String query3 ="INSERT INTO OrderDetail VALUES ('',?,?,?)";
Enumeration products = basket.getProducts();
while(products.hasMoreElements())
{
Product product = (Product)products.nextElement();
Stmt3 = connection.prepareStatement(query3);
Stmt3.setLong(1,order_id);
Stmt3.setInt(2,Integer.parseInt(product.getId()));
Stmt3.setInt(3,product.getQuantity());
Stmt3.executeUpdate();
}
String query4="INSERT INTO Payment VALUES ('',?,?,?,?,?,?)";
java.sql.PreparedStatement Stmt4 = connection.PrepareStatement(query4);
Stmt4.setLong(1,order_id);
Stmt4.setString(2, request.getParameter("card_type");
Stmt4.setString(3, request.getParameter("card_number");
Stmt4.setString(4, request.getParameter("issue_no");
Stmt4.setString(5, request.getParameter("valid_from");
Stmt4.setString(6, request.getParameter("valid_to");
Stmt4.executeUpdate(query4);
Stmt.close();
Stmt2.close();
Stmt3.close();
Stmt4.close();
connection.close();
basket.emptyBasket();
%>
Thanks for your order. It will be processed within 24 hours.
Please note that your Order Number is No: <%= order_id %>
<br/><br/>
<a href=" <%= response.encodeURL("shop-products.jsp" %> ">
<img src="images\toshop.gif" border="0" alt="Return to the Shop"></a>
</body>
</html>
These are the errors I get:
org.apache.jasper.JasperException: Unable to compile class for JSPNote: sun.tools.javac.Main has been deprecated.
An error occurred between lines: 13 and 77 in the jsp file: /Novum/shop-postorder.jsp
Generated servlet error:
C:\Tomcat\jakarta-tomcat-4.0.4\work\Standalone\localhost\_\Novum\shop_0002dpostorder$jsp.java:111: Method getLastInsertID() not found in class sun.jdbc.odbc.JdbcOdbcDriver.
long customer_id = ((sun.jdbc.odbc.JdbcOdbcDriver)Stmt).getLastInsertID();
^
An error occurred between lines: 13 and 77 in the jsp file: /Novum/shop-postorder.jsp
Generated servlet error:
C:\Tomcat\jakarta-tomcat-4.0.4\work\Standalone\localhost\_\Novum\shop_0002dpostorder$jsp.java:114: Method PrepareStatement(java.lang.String) not found in interface java.sql.Connection.
java.sql.PreparedStatement Stmt2 = connection.PrepareStatement(query2);
^
An error occurred between lines: 13 and 77 in the jsp file: /Novum/shop-postorder.jsp
Generated servlet error:
C:\Tomcat\jakarta-tomcat-4.0.4\work\Standalone\localhost\_\Novum\shop_0002dpostorder$jsp.java:121: Method getLastInsertID() not found in class sun.jdbc.odbc.JdbcOdbcDriver.
long order_id = ((sun.jdbc.odbc.JdbcOdbcDriver)Stmt).getLastInsertID();
^
An error occurred between lines: 13 and 77 in the jsp file: /Novum/shop-postorder.jsp
Generated servlet error:
C:\Tomcat\jakarta-tomcat-4.0.4\work\Standalone\localhost\_\Novum\shop_0002dpostorder$jsp.java:129: Undefined variable: Stmt3
Stmt3 = connection.prepareStatement(query3);
^
An error occurred between lines: 13 and 77 in the jsp file: /Novum/shop-postorder.jsp
Generated servlet error:
C:\Tomcat\jakarta-tomcat-4.0.4\work\Standalone\localhost\_\Novum\shop_0002dpostorder$jsp.java:130: Undefined variable or class name: Stmt3
Stmt3.setLong(1,order_id);
^
An error occurred between lines: 13 and 77 in the jsp file: /Novum/shop-postorder.jsp
Generated servlet error:
C:\Tomcat\jakarta-tomcat-4.0.4\work\Standalone\localhost\_\Novum\shop_0002dpostorder$jsp.java:131: Undefined variable or class name: Stmt3
Stmt3.setInt(2,Integer.parseInt(product.getId()));
^
An error occurred between lines: 13 and 77 in the jsp file: /Novum/shop-postorder.jsp
Generated servlet error:
C:\Tomcat\jakarta-tomcat-4.0.4\work\Standalone\localhost\_\Novum\shop_0002dpostorder$jsp.java:132: Undefined variable or class name: Stmt3
Stmt3.setInt(3,product.getQuantity());
^
An error occurred between lines: 13 and 77 in the jsp file: /Novum/shop-postorder.jsp
Generated servlet error:
C:\Tomcat\jakarta-tomcat-4.0.4\work\Standalone\localhost\_\Novum\shop_0002dpostorder$jsp.java:133: Undefined variable or class name: Stmt3
Stmt3.executeUpdate();
^
An error occurred between lines: 13 and 77 in the jsp file: /Novum/shop-postorder.jsp
Generated servlet error:
C:\Tomcat\jakarta-tomcat-4.0.4\work\Standalone\localhost\_\Novum\shop_0002dpostorder$jsp.java:137: Method PrepareStatement(java.lang.String) not found in interface java.sql.Connection.
java.sql.PreparedStatement Stmt4 = connection.PrepareStatement(query4);
^
An error occurred between lines: 13 and 77 in the jsp file: /Novum/shop-postorder.jsp
Generated servlet error:
C:\Tomcat\jakarta-tomcat-4.0.4\work\Standalone\localhost\_\Novum\shop_0002dpostorder$jsp.java:150: Undefined variable or class name: Stmt3
Stmt3.close();
^
10 errors, 1 warning
at org.apache.jasper.compiler.Compiler.compile(Compiler.java:285)
at org.apache.jasper.servlet.JspServlet.loadJSP(JspServlet.java:548)
at org.apache.jasper.servlet.JspServlet$JspServletWrapper.loadIfNecessary(JspServlet.java:176)
at org.apache.jasper.servlet.JspServlet$JspServletWrapper.service(JspServlet.java:188)
at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:381)
at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:473)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:247)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:193)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:243)
at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:566)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:472)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:943)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:190)
at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:566)
at org.apache.catalina.valves.CertificatesValve.invoke(CertificatesValve.java:246)
at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:564)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:472)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:943)
at org.apache.catalina.core.StandardContext.invoke(StandardContext.java:2347)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:180)
at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:566)
at org.apache.catalina.valves.ErrorDispatcherValve.invoke(ErrorDispatcherValve.java:170)
at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:564)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:170)
at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:564)
at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:468)
at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:564)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:472)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:943)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:174)
at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:566)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:472)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:943)
at org.apache.catalina.connector.http.HttpProcessor.process(HttpProcessor.java:1027)
at org.apache.catalina.connector.http.HttpProcessor.run(HttpProcessor.java:1125)
at java.lang.Thread.run(Thread.java:536)