Help With Debugging
[nobr]im doing a shopping Cart with an MS ACCESS DB...
Im trying to get it to input the details of the order the code is as follows:
<%@ page contentType="text/html; charset=iso-8859-1" language="java" import="java.text.SimpleDateFormat,java.sql.*,java.util.*,basket.ShoppingBasket, basket.Product" errorPage="" %>
<html>
<head>
<title>West Wrights Oatcakes - Process Order</title>
</head>
<body>
<jsp:useBean id="basket" class="basket.ShoppingBasket" scope="session"/>
<%
try
{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver").newInstance();
Connection conn = DriverManager.getConnection("jdbc:odbc:Driver={Microsoft Access Driver (*.mdb)};DBQ=C:/Program Files/Apache Software Foundation/Tomcat 5.5/webapps/ROOT/Assignment/Db1.mdb;");
Statement statement = conn.createStatement();
Enumeration parameters = request.getParameterNames();
SimpleDateFormat dbtimedatestampformat =new SimpleDateFormat("MM/dd/yyyy");
java.util.Date date =new java.util.Date();
String dbtimedatestamp = (dbtimedatestampformat.format(date));
String emailParam = request.getParameter("email");
String postParam = request.getParameter("radiobutton");
Double total = basket.getTotal();
String query ="INSERT INTO TblTransaction VALUES (#" + dbtimedatestamp +"#,'',?,'"+emailParam+"')";
java.sql.PreparedStatement stment = conn.prepareStatement(query);
if(parameters.hasMoreElements())
{
statement.executeUpdate("INSERT INTO TblOrder (\"Email\", \"Date\", \"Total\", \"Post\") VALUES ('"+emailParam+"',#" + dbtimedatestamp +"#,'"+total+"','"+postParam+"')");
out.print("mooooo");
Enumeration products = basket.getProducts();
Product product = (Product)products.nextElement();
while(products.hasMoreElements())
{
//Product product = (Product)products.nextElement();
stment = conn.prepareStatement(query);
stment.setString(2,product.getId());
out.print("dad");
stment.setInt(3,product.getQuantity());
out.print("mum");
stment.executeUpdate();
}
}
statement.close();
stment.close();
conn.close();
basket.emptyBasket();
}
catch (Exception e){out.print(e);
}
%>
Thank youfor your order.
The order will be processed within the next 10 minutes <br>
Please note during busy periods orders may take longer to process<br>
<br>
<a href="<%=response.encodeURL("shop-products.jsp")%> ">Return to shop</a>
</body>
</html>
The error i am getting is this:
java.lang.ArrayIndexOutOfBoundsException: 1
can anyone help?
Many thanks in advance[/nobr]

