Help with odd error

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

Help with odd error

SkipDever
I have this code:
...
            TransactionUtil.begin();
            System.out.println("*************************Creating the list
iterator");
        iter = delegator.findListIteratorByCondition("ItemsSold",
conditionList, null, UtilMisc.toList("productId", "facilityId"));
            System.out.println("Creating the list iterator finished");
            TransactionUtil.commit();

...
       if(iter != null)
                  System.out.println("*************************Calling
Next");
        iItemSold = (GenericValue)iter.next();
                  System.out.println("Calling Next returns product " +
itemSold.getString("productId"));


I am getting this error:
java.sql.SQLException: ResultSet not open. Operation 'next' not permitted.
Verify that autocommit is OFF.

at EntityListIterator.next() line 289 which just calls resultSet.next();

This is with derby.  I have just moved back to a development machine.  This
runs fine on Postgres and I swear it used to work fine on derby.

The debug trace code shows that the iterator gets opened and it fails on the
first call to iter.next();  The only code around the elipses are a catch
block, no db access of any sort.

Anyone have a clue?

Skip


No virus found in this outgoing message.
Checked by AVG.
Version: 7.5.519 / Virus Database: 269.22.13/1377 - Release Date: 4/14/2008
9:26 AM

Reply | Threaded
Open this post in threaded view
|

Re: Help with odd error

Scott Gray
Shouldn't the iteration be part of the transaction?  Perhaps derby closes
the result set after TransactionUtil.commit()? The error message mentions
turning autocommit off, which suggests that premature committing might be
the problem.

Regards
Scott

On 18/04/2008, skip@thedevers <[hidden email]> wrote:

>
> I have this code:
> ...
>             TransactionUtil.begin();
>             System.out.println("*************************Creating the list
> iterator");
>                 iter = delegator.findListIteratorByCondition("ItemsSold",
> conditionList, null, UtilMisc.toList("productId", "facilityId"));
>             System.out.println("Creating the list iterator finished");
>             TransactionUtil.commit();
>
> ...
>        if(iter != null)
>
> System.out.println("*************************Calling
> Next");
>                                 iItemSold = (GenericValue)iter.next();
>                            System.out.println("Calling Next returns
> product " +
> itemSold.getString("productId"));
>
>
> I am getting this error:
> java.sql.SQLException: ResultSet not open. Operation 'next' not permitted.
> Verify that autocommit is OFF.
>
> at EntityListIterator.next() line 289 which just calls resultSet.next();
>
> This is with derby.  I have just moved back to a development
> machine.  This
> runs fine on Postgres and I swear it used to work fine on derby.
>
> The debug trace code shows that the iterator gets opened and it fails on
> the
> first call to iter.next();  The only code around the elipses are a catch
> block, no db access of any sort.
>
> Anyone have a clue?
>
> Skip
>
>
> No virus found in this outgoing message.
> Checked by AVG.
> Version: 7.5.519 / Virus Database: 269.22.13/1377 - Release Date:
> 4/14/2008
> 9:26 AM
>
>
Reply | Threaded
Open this post in threaded view
|

RE: Help with odd error

SkipDever
Scott

Forgot to mention. That I originally had the iter.next() inside the
transaction like this:

xaction = TransactionUtil.begin();
        iter.next() <---- fails on the second pass through with the ResultSet
closed
        do some work
TransactionUtil.commit();

Skip

-----Original Message-----
From: Scott Gray [mailto:[hidden email]]
Sent: Friday, April 18, 2008 2:25 AM
To: [hidden email]
Subject: Re: Help with odd error


Shouldn't the iteration be part of the transaction?  Perhaps derby closes
the result set after TransactionUtil.commit()? The error message mentions
turning autocommit off, which suggests that premature committing might be
the problem.

Regards
Scott

On 18/04/2008, skip@thedevers <[hidden email]> wrote:

>
> I have this code:
> ...
>             TransactionUtil.begin();
>             System.out.println("*************************Creating the list
> iterator");
>                 iter = delegator.findListIteratorByCondition("ItemsSold",
> conditionList, null, UtilMisc.toList("productId", "facilityId"));
>             System.out.println("Creating the list iterator finished");
>             TransactionUtil.commit();
>
> ...
>        if(iter != null)
>
> System.out.println("*************************Calling
> Next");
>                                 iItemSold = (GenericValue)iter.next();
>                            System.out.println("Calling Next returns
> product " +
> itemSold.getString("productId"));
>
>
> I am getting this error:
> java.sql.SQLException: ResultSet not open. Operation 'next' not permitted.
> Verify that autocommit is OFF.
>
> at EntityListIterator.next() line 289 which just calls resultSet.next();
>
> This is with derby.  I have just moved back to a development
> machine.  This
> runs fine on Postgres and I swear it used to work fine on derby.
>
> The debug trace code shows that the iterator gets opened and it fails on
> the
> first call to iter.next();  The only code around the elipses are a catch
> block, no db access of any sort.
>
> Anyone have a clue?
>
> Skip
>
>
> No virus found in this outgoing message.
> Checked by AVG.
> Version: 7.5.519 / Virus Database: 269.22.13/1377 - Release Date:
> 4/14/2008
> 9:26 AM
>
>

No virus found in this incoming message.
Checked by AVG.
Version: 7.5.519 / Virus Database: 269.22.13/1377 - Release Date: 4/14/2008
9:26 AM

No virus found in this outgoing message.
Checked by AVG.
Version: 7.5.519 / Virus Database: 269.22.13/1377 - Release Date: 4/14/2008
9:26 AM

Reply | Threaded
Open this post in threaded view
|

RE: Help with odd error

SkipDever
In reply to this post by Scott Gray
Scott

That was indeed the problem.  The resultset was getting tossed on the
commit().  However, that is not the behavior I was trying to achieve.  I did
not want the EntityListIterator even part of the transaction, but if you
don't have it, you get this big complaint in the debug log.

Furthermore, If I have a naked commit() anywhere, the EntityListIterator
ResultSet gets tossed.  By naked, I mean without the boolean argument.  In
other words:

xaction = TransactionUtil.begin();
        do some work
TransactionUtil.commit();
iter.next() <---- fails

xaction = TransactionUtil.begin();
        do some work
TransactionUtil.commit(xaction);
iter.next() <---- Succeeds because xaction is false

I am still working on this.  I expect it will take me a couple of days to
get all the way through this code.  I don't like these mysteries.

Skip


-----Original Message-----
From: Scott Gray [mailto:[hidden email]]
Sent: Friday, April 18, 2008 2:25 AM
To: [hidden email]
Subject: Re: Help with odd error


Shouldn't the iteration be part of the transaction?  Perhaps derby closes
the result set after TransactionUtil.commit()? The error message mentions
turning autocommit off, which suggests that premature committing might be
the problem.

Regards
Scott

On 18/04/2008, skip@thedevers <[hidden email]> wrote:

>
> I have this code:
> ...
>             TransactionUtil.begin();
>             System.out.println("*************************Creating the list
> iterator");
>                 iter = delegator.findListIteratorByCondition("ItemsSold",
> conditionList, null, UtilMisc.toList("productId", "facilityId"));
>             System.out.println("Creating the list iterator finished");
>             TransactionUtil.commit();
>
> ...
>        if(iter != null)
>
> System.out.println("*************************Calling
> Next");
>                                 iItemSold = (GenericValue)iter.next();
>                            System.out.println("Calling Next returns
> product " +
> itemSold.getString("productId"));
>
>
> I am getting this error:
> java.sql.SQLException: ResultSet not open. Operation 'next' not permitted.
> Verify that autocommit is OFF.
>
> at EntityListIterator.next() line 289 which just calls resultSet.next();
>
> This is with derby.  I have just moved back to a development
> machine.  This
> runs fine on Postgres and I swear it used to work fine on derby.
>
> The debug trace code shows that the iterator gets opened and it fails on
> the
> first call to iter.next();  The only code around the elipses are a catch
> block, no db access of any sort.
>
> Anyone have a clue?
>
> Skip
>
>
> No virus found in this outgoing message.
> Checked by AVG.
> Version: 7.5.519 / Virus Database: 269.22.13/1377 - Release Date:
> 4/14/2008
> 9:26 AM
>
>

No virus found in this incoming message.
Checked by AVG.
Version: 7.5.519 / Virus Database: 269.22.13/1377 - Release Date: 4/14/2008
9:26 AM

No virus found in this outgoing message.
Checked by AVG.
Version: 7.5.519 / Virus Database: 269.22.13/1377 - Release Date: 4/14/2008
9:26 AM