File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Struts and the fly likes Cannot create stmt more than once Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


JavaRanch » Java Forums » Frameworks » Struts
Bookmark "Cannot create stmt more than once" Watch "Cannot create stmt more than once" New topic
Author

Cannot create stmt more than once

Rajeev Motiani
Greenhorn

Joined: Dec 09, 2003
Posts: 2
Environment: Created an struts application connected to MS Access. The conection created through JDBC-ODBC bridge using the Class for name (classes12.zip driver) in java.

Issue: We are able to access the database through struts form the first time through JSP, however once we refresh or request the same page again, it creates the connection but cannot create the statement ie. the error comes at point stmt =con.createStatement();

We have checked the program works if we call the method from normal jsp-java rather than struts framework. What settings are misisng?
Peter den Haan
author
Ranch Hand

Joined: Apr 20, 2000
Posts: 3252
1. Classes12.zip is the Oracle JDBC driver; not sure where it fits in. I will assume you're actually not using this at all.

2. You give neither the precise error you get nor a stack trace. Without that, we're flying blind.

3. It is unlikely to have anything to do with Struts as such; Struts doesn't touch the database. If you're using the DataSource that Struts can give you, but are not using a DataSource in your JSPs, that might well be the difference. Are you sure you are closing your ResultSets and Statements before you close the connection (i.e. return it to the pool)?

4. The JDBC-ODBC bridge has some pretty serious restrictions and is not supported for production purposes. One restriction I know of is that you cannot have more than one result set open on a single connection. I'm not aware of a restriction on the number of statements.

5. Access is not generally considered fit for this purpose. It may well bring restrictions of its own, but I'm not familiar enough with it to say.

If I were in your shoes I'd try to get away from both Access and the JDBC-ODBC bridge.

- Peter
 
GeeCON Prague 2014
 
subject: Cannot create stmt more than once