David
I am using a GenericDatasource to establish a connection to a mysql database.
The connection get established all right, but when I try to walk the
ResultSet, I do get an SQLException which interprets as the ResultSet having been
closed. Can someone please explain why a ResultSet object cannot be iterated or
walked through even before I close the connection to the database?
Exception(java.sql.SQLException: Operation not allowed after ResultSet closed) occurs when I try to call the method next() of java.sql.ResultSet
A snippet of the code in my Action class read as follows:
private ResultSet myResultSet; ------
-------
HttpSession session = request.getSession();
try { dataSource = getDataSource(request); myConnection = dataSource.getConnection();
Statement stmt = myConnection.createStatement();
myResultSet = stmt.executeQuery("SELECT * FROM my_table ORDER BY
id ;");
this.setResultSet(myResultSet);
} catch (SQLException sqle) {
}
ArrayList bookArrayList = new ArrayList(); try { ResultSet res = this.getResultSet(); while (res.next()) { Book book = new Book(); book.setEnglishISBN(res.getString("isbn"));
book.setEnglishAUTHOR(res.getString("author"));
bookArrayList.add(book); } } catch (SQLException ignored) {
}
session.setAttribute("Books", bookArrayList);
if (myConnection != null) {
try { myConnection.close(); } catch (SQLException e) {
} } return (mapping.findForward("ignoredPage")); }
public void setResultSet(ResultSet res) { this.myResultSet = res; }
public ResultSet getResultSet() { return this.myResultSet; }
_________________________________________________________________
Tired of spam? Get advanced junk mail protection with MSN 8. http://join.msn.com/?page=features/junkmail
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]