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

Cannot create stmt more than once

Rajeev Motiani

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 ( 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
Ranch Hand

Joined: Apr 20, 2000
Posts: 3252
1. 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
I agree. Here's the link:
subject: Cannot create stmt more than once
jQuery in Action, 3rd edition