exactly!
The connection is associated with the PB instance. When the PB instance was closed or the current PB-tx end all resources became unvalid.
E.g. the connection returned to the pool on PB.close may used by another thread/PB instance and when RsIterator does not close all resources it may happend that RsIterator use the same connection as a concurrent thread and bad things can start happen ...
You can find comments in RsIterator javadoc, in RsIterator source code and some posts at the user-list.
regards, Armin
Info wrote:
Hello week end mid-night!
I know the reason. Actually, after I get Iterator, this time OJB hasn't get whole data set yet. So I only get a interface, every time I invoke next(), the Iterator(RsIterator) will retrieve the data from database. So I can't return Iterator from a method. Because, before return the Iterator the following code will be executed:
} finally { if (broker != null) { broker.close(); } } my database connection has been close before I process the Iterator.
I have to retrieve the data from Iterator manually before I return. I guess OJB intend to minimize the database access from Iterator mode.
Thanks, Wallace
Info wrote:
Hello Everybody! I am working through the week end.
---------------------------------------------------------------------------------
J2SE 1.4.2_04 + OJB 1.0 rc6 + Struts 1.1 + J2EE (just in classpath)
---------------------------------------------------------------------------------
I am geting a report query by:
broker = PersistenceBrokerFactory.defaultPersistenceBroker();
Criteria crit = new Criteria();
ReportQueryByCriteria q = QueryFactory.newReportQuery(ThreadDto.class, crit);
q.setAttributes(new String[]{"priority", "username"});
Iterator it = broker.getReportQueryIteratorByQuery(q);
while (it.hasNext()){
it.next();......................
.....................
}
but from line: while (it.hasNext()) get the following exception
org.apache.ojb.broker.accesslayer.RsIterator$ResourceClosedException: Resources no longer reachable, RsIterator will be automatic cleaned up on PB.close/.commitTransaction/.abortTransaction
at org.apache.ojb.broker.accesslayer.RsIterator.getRsAndStmt(RsIterator.java:876)
at org.apache.ojb.broker.accesslayer.RsIterator.hasNext(RsIterator.java:228)
I tried to use Query instead of report query, and let it returns a Colleciton, everything is fine.
Later, I still used Query, but ask it return a Iterator (by method: getIteratorByQuery()), I get the same exception as above. It looks like not caused by report query but by Iterator return.
Please give advice,
Thanks! Wallace
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
