groovy-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Owen Rubel <oru...@gmail.com>
Subject Re: groovy.sql.Sql - When is the connection actually made?
Date Thu, 30 Apr 2015 05:03:58 GMT
Just in case you are asking about connection pools, you can use grails
datasource for defining the pool.

here's a good thread on that...

http://stackoverflow.com/questions/12291930/connection-pooling-and-prepared-statements-with-groovy-sql-sql-or-jdbc-in-grails


On Wed, Apr 29, 2015 at 8:22 PM, Dinko Srko─Ź <dinko.srkoc@gmail.com> wrote:

>
> On 29 Apr 2015 23:10, "Henson Sturgill" <henson.reset@gmail.com> wrote:
> >
> > Been playing around with a hosted Oracle database that *seems* to be
> dropping connections. I made the following script to test (call to
> Sql.newInstance() not shown) but I'm curious -- does Groovy create the
> connection to the database on newInstance(), or every time eachRow() is
> called?
> >
>
> Every time eachRow is called, and the connection is closed upon consuming
> the dataset.
>
> Cheers,
> Dinko
>
> > --- Example Code ---
> >
> > String query = "select count(*) cnt from spriden where
> upper(spriden_last_name) = 'STURGILL'"
> > int minuteDelay = 0
> >
> > while (minuteDelay <= 120) {
> >     Thread.sleep(1000 * 60 * minuteDelay); // Sleep increasing number of
> minutes
> >     Date date = new Date();
> >     sql.eachRow(query) {
> >         println "After ${minuteDelay} minutes - ${it.cnt} (${date})"
> >     }
> >     minuteDelay += 5;
> > }
> >
> > --- End Example ---
> >
> > Thanks so much you wonderful programmers!
>

Mime
View raw message