Win a copy of Hands On Software Engineering with Python this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Bear Bibeault
  • Knute Snortum
  • Liutauras Vilda
Sheriffs:
  • Tim Cooke
  • Devaka Cooray
  • Paul Clapham
Saloon Keepers:
  • Tim Moores
  • Frits Walraven
  • Ron McLeod
  • Ganesh Patekar
  • salvin francis
Bartenders:
  • Tim Holloway
  • Carey Brown
  • Stephan van Hulst

Servlet, JSP and access violation 0xc 0000005  RSS feed

 
Ranch Hand
Posts: 18944
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am designing a shopping cart using servlets, jsp pages and jdbc. I am conducting test on a windows NT server with Tomcat and an Access database.
Each time I succeed to write a new field in the tables 'sysgen' and 'client', it generates an error with java.exe:
Exception: access violation Oxc 0000005
Address: 0x1f43b3f0
Could you help me?
Here is my code:
public class CheckOut extends HttpServlet {
private String databaseUrl;
private Connection connection;

public void init(ServletConfig config) throws ServletException {
super.init(config);
databaseUrl = "jdbc dbc:testlit";
connection = null;
try
{
String driverName = "sun.jdbc.odbc.JdbcOdbcDriver";
Class.forName(driverName).newInstance();
}
catch ( Exception e )
{
throw new ServletException("Failed to load driver" + e.getMessage());
}
}

public void doGet(HttpServletRequest request,
HttpServletResponse response)
throws ServletException, IOException {
HttpSession session = request.getSession(true);
ShoppingCart cart;
ResultSet result;
long itemID;
long oiTable;
long oiClient;
// String updateTemplate = "INSERT into literature (oi, itemid, description, numitems) VALUES (?, ?, ?, ?)";
synchronized(session) {
cart = (ShoppingCart)session.getValue("shoppingCart");
Vector itemsOrdered = cart.getItemsOrdered();
if (itemsOrdered.size() == 0) {
System.out.println("No items in your cart...");
} else {
// If there is at least one item in cart, save it into the database
ItemOrder order;
try
{
connection = DriverManager.getConnection(databaseUrl, "", "");
// connection.setAutoCommit(false);
Statement oiStatement = connection.createStatement();
result = oiStatement.executeQuery("SELECT litId FROM sysgen");
if (!result.next()) {
throw new ServletException("Failed to generate id.");
}
oiTable = result.getLong(1);
oiTable++;
result.next();
oiClient = result.getLong(1);
oiClient++;
oiStatement.close();
String titre = request.getParameter("titre");
titre = replaceIfMissing(titre, "not entered");
String prenom = request.getParameter("prenom");
prenom = replaceIfMissing(prenom, "not entered");
String nom = request.getParameter("nom");
nom = replaceIfMissing(nom, "not entered");
String address = request.getParameter("address");
address = replaceIfMissing(address, "not entered");
String city = request.getParameter("city");
city = replaceIfMissing(city, "not entered");
String zip = request.getParameter("zip");
zip = replaceIfMissing(zip, "not entered");
String country = request.getParameter("country");
country = replaceIfMissing(country, "not entered");
String states = request.getParameter("states");
states = replaceIfMissing(states, "not entered");
String phonenumber = request.getParameter("phonenumber");
phonenumber = replaceIfMissing(phonenumber, "not entered");
String faxnumber = request.getParameter("faxnumber");
faxnumber = replaceIfMissing(faxnumber, "not entered");
String email = request.getParameter("email");
email = replaceIfMissing(email, "not entered");
Statement clstmt = connection.createStatement();
clstmt.executeUpdate("INSERT into client " +
"(idclient, titre, prenom, nom, address, city, zip, country, states, phonenumber, faxnumber, email) " +
"VALUES (" + oiClient +", '" + titre +
"', '" + prenom +
"', '" + nom +
"', '" + address +
"', '" + city +
"', '" + zip +
"', '" + country +
"', '" + states +
"', '" + phonenumber +
"', '" + faxnumber +
"', '" + email + "')");
clstmt.close();
Statement pmt = connection.createStatement();
pmt.executeUpdate("UPDATE sysgen SET litId = " + oiClient +" WHERE sysId = 2");
pmt.close();
Statement stamt = connection.createStatement();
for(int i=0; i<itemsOrdered.size(); i++) {
order = (ItemOrder)itemsOrdered.elementAt(i);
itemID = Long.parseLong(order.getItemID());
stamt.executeUpdate("INSERT into literature " +
"(oi, itemid, description, numitems, idclient) " +
"VALUES (" + oiTable +"," + itemID +", '" +
order.getShortDescription() +"'," + order.getNumItems() +"," + oiClient +")");
oiTable++;
}

stamt.close();
Statement stmt = connection.createStatement();
stmt.executeUpdate("UPDATE sysgen SET litId = " + oiTable +" WHERE sysId = 1");
stmt.close();
connection.close();
}
catch ( SQLException e )
{
System.out.println("Error executing statement");
}
}
}
gotoPage("/merci.jsp", request, response);
}
 
Squanch that. And squanch this tiny ad:
ScroogeXHTML 8.0 - RTF to HTML5 and XHTML converter
https://coderanch.com/t/704747/ScroogeXHTML-RTF-HTML-XHTML-converter
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!