Java Mailing List Archive

http://www.gg3721.com/

Home » user.groovy »

[groovy-user] Re: No errors/exceptions when using Sql.eachRow in Groovy 1.8.5

Dan Fraser

2012-02-05

Replies: Find Java Web Hosting

Author LoginPost Reply
Hi, Dinko!  Thanks for doing the test. I re-wrote the code in Plain Old Java to see what was going on. I had the connection.close() in a finally block, which was blocking the termination of the program (including throwing exceptions) for some odd MySQL reason.  Groovy must put a try/finally around the sql operations. 

So there we go... it is a combination of finally and MySQL weirdness.  

Thanks again for testing.  It's not Groovy's fault at all. :)

--
Dan Fraser

On Feb 4, 2012, at 13:09, "Dinko Srkoc [via Groovy]" <[hidden email]> wrote:

Hi Dan,

I tried your example with both Informix and PostgreSQL but was unable
to reproduce the problem. The things I had to change to be able to run
the example are:

* set the fetchSize to a positive number
* removed the  "`" from the query

I don't think the culprit is groovy.sql.Sql as I don't see anything in
the source that would cause the hang, could it be MySQL's driver? Have
you tried another DBMS?

Cheers,
Dinko

On 3 February 2012 15:07, dfraser <[hidden email]> wrote:

> The output from the following script on my system is:
>
> dfraser$ groovy -cp ../lib/mysql-connector-java-5.1.18-bin.jar
> Poptool.groovy
> fizz
> in loop
> [hang]
>
> It doesn't actually exit or print anything else.
>
> Do you see a problem?
>
> If I remove the throw, it gets to about 11500 rows and then hangs, probably
> due to an exception, and I'm not sure why because there is no error message!
>
> --snip--
>
> package com.company.poptool
>
> import groovy.sql.Sql
>
> def sql = Sql.newInstance("jdbc:mysql://localhost:3306/pop", "user",
>                      "pass", "com.mysql.jdbc.Driver")
>
> sql.withStatement{ stmt -> stmt.fetchSize = Integer.MIN_VALUE }
>
> def archiveTable = 'arch_2012-01-16'
> def count = 0;
>
> println("fizz")
> sql.eachRow("select * from `${Sql.expand archiveTable}`") { row ->
>        count ++
>        println("in loop")
>        if (count % 100 == 0) {
>                println count
>        }
>        throw new IllegalArgumentException("boo!")
> }
> println("buzz")
>
>
>
> --
> View this message in context: http://groovy.329449.n5.nabble.com/No-errors-exceptions-when-using-Sql-eachRow-in-Groovy-1-8-5-tp5451985p5453942.html
> Sent from the groovy - user mailing list archive at Nabble.com.
>
> ---------------------------------------------------------------------
> To unsubscribe from this list, please visit:
>
>    http://xircles.codehaus.org/manage_email
>
>
---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email





If you reply to this email, your message will be added to the discussion below:
http://groovy.329449.n5.nabble.com/No-errors-exceptions-when-using-Sql-eachRow-in-Groovy-1-8-5-tp5451985p5456593.html
To unsubscribe from No errors/exceptions when using Sql.eachRow in Groovy 1.8.5, click here.
NAML


View this message in context: Re: No errors/exceptions when using Sql.eachRow in Groovy 1.8.5
Sent from the groovy - user mailing list archive at Nabble.com.
©2008 gg3721.com - Jax Systems, LLC, U.S.A.