I'm trying to write a short groovy script to do a sql query. I got it working by explicitly setting the classpath to point to the Oracle driver jar, but I'd prefer to have this work with Grape.
I have the Oracle driver jar on a Nexus repo on our intranet.
This is my prototype script:
-----------------
#! env groovy
//@GrabResolver(name='OurRepo', root='http://...')
//@Grab(group='oracle.jdbc', module='oracle.jdbc.OracleDriver', version='1.0.0')
import groovy.sql.Sql
sql = Sql.newInstance('jdbc:oracle:thin:@host:1521:cclabprd',
'cclabro', 'password', 'oracle.jdbc.driver.OracleDriver')
sql.eachRow("select gd.GRPDSCRPTN_TITLE from GRPDSCRPTN gd join GROUPUSERS gu on gu.GROUPUSERS_GROUPID = gd.GRPDSCRPTN_ID join USER_VIEW u on u.ID = gu.GROUPUSERS_USERID where u.login = 'us2300'") { println "$it" }
---------------------
This runs quickly when I run it with a "-cp" command-line parameter pointing to my local install of the "ojdbc6.jar".
When I instead comment back in the @GrabResolver and @Grab lines, and then add "-Dgroovy.grape.report.downloads=true" to the command line, it prints the following and then hangs:
------------------
Resolving dependency: oracle.jdbc#oracle.jdbc.OracleDriver;1.0.0 {default=[default]}
------------------
I first ran this with Groovy 2.2.2. I also tried it with 2.3.0-beta2, but that fails with an even more useless error:
----------------------
Caught: java.net.MalformedURLException: unknown protocol: c
java.net.MalformedURLException: unknown protocol: c
-----------------------
When I added "-d" to the command line, I get this:
----------------------
at java.net.URL.<init>(URL.java:592)
at java.net.URL.<init>(URL.java:482)
at java.net.URL.<init>(URL.java:431)
at java.net.URI.toURL(URI.java:1096)
at groovy.lang.GroovyCodeSource.<init>(GroovyCodeSource.java:162)
at groovy.ui.GroovyMain.getScriptSource(GroovyMain.java:448)
at groovy.ui.GroovyMain.processOnce(GroovyMain.java:627)
at groovy.ui.GroovyMain.run(GroovyMain.java:379)
at groovy.ui.GroovyMain.process(GroovyMain.java:365)
at groovy.ui.GroovyMain.processArgs(GroovyMain.java:124)
at groovy.ui.GroovyMain.main(GroovyMain.java:104)
....
--------------
I'm running this in Cygwin, so perhaps something is getting confused about navigating the PATH.
---------------------------------------------------------------------
To unsubscribe from this list, please visit:
http://xircles.codehaus.org/manage_email