You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@groovy.apache.org by Richard Heintze <si...@yahoo.com> on 2016/01/10 07:25:41 UTC

Wanted: help with using jdbc grapes in groovy shell?

 Why does the groovy shell require a special syntax?
I'm trying to make this work in the groovyConsole.
@GrabConfig(systemClassLoader=true)
groovy.grape.Grape.grab(group:'net.sf.ucanaccess', module:'ucanaccess', version:'3.0.1')
sql = groovy.sql.Sql.newInstance("jdbc:ucanaccess://"+ System.getenv()['USERPROFILE']+ "\\Documents\\bin\\BackupRecords.mdb","net.ucanaccess.jdbc.UcanaccessDriver"); sql.eachRow("SELECT pattern FROM FileNamePattern, (SELECT idFileNamePattern FROM FileNamePatternGroupToFileNamePattern WHERE idFileExclusionGroup=( SELECT idFileExclusionGroup FROM Directory WHERE directory=:dir)) WHERE id = idFileNamePattern  ", [dir:"%USERPROFILE%\\Documents\\WinOOP"]){ println it }
The first line does not work well! Can someone show me out to use the class loader in the groovy console?
Unfortunately, the blog that explained how to do this is now gone.
ThanksSiegfried

Re: Wanted: help with using jdbc grapes in groovy shell?

Posted by James Northrop <ja...@orange.fr>.
Bonjour Richard,

Got a bit farther by changing the : symbols to = symbols as:

@GrabConfig(systemClassLoader=true)
@Grab(group='net.sf.ucanaccess', module='ucanaccess', version='3.0.1')

sql = groovy.sql.Sql.newInstance("jdbc:ucanaccess://"+ System.getenv()['USERPROFILE']+ "\\Documents\\bin\\BackupRecords.mdb","net.ucanaccess.jdbc.UcanaccessDriver");
println "--- the end ---"

but still failed to work on my sys as i do not have null\Documents\bin\BackupRecords.mdb  so maybe if u try this version you may have some joy !  Have a GR8 day !
thx jim




















On Jan 10, 2016, at 7:25 AM, Richard Heintze wrote:

> @GrabConfig(systemClassLoader=true)
> groovy.grape.Grape.grab(group:'net.sf.ucanaccess', module:'ucanaccess', version:'3.0.1')
> sql = groovy.sql.Sql.newInstance("jdbc:ucanaccess://"+ System.getenv()['USERPROFILE']+ "\\Documents\\bin\\BackupRecords.mdb","net.ucanaccess.jdbc.UcanaccessDriver");


Re: Wanted: help with using jdbc grapes in groovy shell?

Posted by jim northrop <ja...@googlemail.com>.
that's two of us as 'idiots' as i msde that same mistake as you, just
earlier ;-D

Parts of the learning curve me thinks LOL

Have a GR8 Monday woncha ?

k/r

Jim

On 11 January 2016 at 05:38, Richard Heintze <si...@yahoo.com> wrote:

> Sorry, I am idiot!
> In previous versions of groovy console this "@Grab" syntax did not work
> you needed to use a function call of Groovy.grape.Grape.grab instead and
> this was a problem with the system class loader jdbc requires.
>
> Apparently groovy console now works with "@Grab".
> Sorry for the spam.
>
>
> On Sunday, January 10, 2016 12:21 AM, James Northrop <
> james.northrop@orange.fr> wrote:
>
>
> just saw this too: the env var USERPROFILE may be obsolete but i tried
>
> up =  System.getenv("USER");
> println up;
>
> and that says
> 'Jim'
>
> ;-)
>
>
> On Jan 10, 2016, at 7:25 AM, Richard Heintze wrote:
>
> Why does the groovy shell require a special syntax?
>
> I'm trying to make this work in the groovyConsole.
>
> @GrabConfig(systemClassLoader=true)
> groovy.grape.Grape.grab(group:'net.sf.ucanaccess', module:'ucanaccess',
> version:'3.0.1')
> sql = groovy.sql.Sql.newInstance("jdbc:ucanaccess://"+
> System.getenv()['USERPROFILE']+ "\\Documents\\bin\\BackupRecords.mdb","net.ucanaccess.jdbc.UcanaccessDriver");
> sql.eachRow("SELECT pattern FROM FileNamePattern, (SELECT idFileNamePattern
> FROM FileNamePatternGroupToFileNamePattern WHERE idFileExclusionGroup=(
> SELECT idFileExclusionGroup FROM Directory WHERE directory=:dir)) WHERE id
> = idFileNamePattern  ", [dir:"%USERPROFILE%\\Documents\\WinOOP"]){ println
> it }
>
> The first line does not work well! Can someone show me out to use the
> class loader in the groovy console?
>
> Unfortunately, the blog that explained how to do this is now gone.
>
> Thanks
> Siegfried
>
>
>
>
>

Re: Wanted: help with using jdbc grapes in groovy shell?

Posted by Richard Heintze <si...@yahoo.com>.
Sorry, I am idiot!In previous versions of groovy console this "@Grab" syntax did not work you needed to use a function call of Groovy.grape.Grape.grab instead and this was a problem with the system class loader jdbc requires.
Apparently groovy console now works with "@Grab".Sorry for the spam. 

    On Sunday, January 10, 2016 12:21 AM, James Northrop <ja...@orange.fr> wrote:
 

 just saw this too: the env var USERPROFILE may be obsolete but i tried
up =  System.getenv("USER");println up;
and that says'Jim'
;-)

On Jan 10, 2016, at 7:25 AM, Richard Heintze wrote:

 Why does the groovy shell require a special syntax?
I'm trying to make this work in the groovyConsole.
@GrabConfig(systemClassLoader=true)
groovy.grape.Grape.grab(group:'net.sf.ucanaccess', module:'ucanaccess', version:'3.0.1')
sql = groovy.sql.Sql.newInstance("jdbc:ucanaccess://"+ System.getenv()['USERPROFILE']+ "\\Documents\\bin\\BackupRecords.mdb","net.ucanaccess.jdbc.UcanaccessDriver"); sql.eachRow("SELECT pattern FROM FileNamePattern, (SELECT idFileNamePattern FROM FileNamePatternGroupToFileNamePattern WHERE idFileExclusionGroup=( SELECT idFileExclusionGroup FROM Directory WHERE directory=:dir)) WHERE id = idFileNamePattern  ", [dir:"%USERPROFILE%\\Documents\\WinOOP"]){ println it }
The first line does not work well! Can someone show me out to use the class loader in the groovy console?
Unfortunately, the blog that explained how to do this is now gone.
ThanksSiegfried



  

Re: Wanted: help with using jdbc grapes in groovy shell?

Posted by James Northrop <ja...@orange.fr>.
just saw this too: the env var USERPROFILE may be obsolete but i tried

up =  System.getenv("USER");
println up;

and that says
'Jim'

;-)


On Jan 10, 2016, at 7:25 AM, Richard Heintze wrote:

> Why does the groovy shell require a special syntax?
> 
> I'm trying to make this work in the groovyConsole.
> 
> @GrabConfig(systemClassLoader=true)
> groovy.grape.Grape.grab(group:'net.sf.ucanaccess', module:'ucanaccess', version:'3.0.1')
> sql = groovy.sql.Sql.newInstance("jdbc:ucanaccess://"+ System.getenv()['USERPROFILE']+ "\\Documents\\bin\\BackupRecords.mdb","net.ucanaccess.jdbc.UcanaccessDriver"); sql.eachRow("SELECT pattern FROM FileNamePattern, (SELECT idFileNamePattern FROM FileNamePatternGroupToFileNamePattern WHERE idFileExclusionGroup=( SELECT idFileExclusionGroup FROM Directory WHERE directory=:dir)) WHERE id = idFileNamePattern  ", [dir:"%USERPROFILE%\\Documents\\WinOOP"]){ println it }
> 
> The first line does not work well! Can someone show me out to use the class loader in the groovy console?
> 
> Unfortunately, the blog that explained how to do this is now gone.
> 
> Thanks
> Siegfried