groovy-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Imholz, John J." <imho...@musc.edu>
Subject RE: Database Drivers
Date Fri, 07 Apr 2017 11:48:53 GMT
The jar is in /usr/share/java

I’m not explicitly loading it. I’m just running “./gradlew console” at the root of
the application.

jji

From: Mario Garcia [mailto:mario.ggar@gmail.com]
Sent: Friday, April 7, 2017 3:25 AM
To: users@groovy.apache.org
Subject: Re: Database Drivers



Hi:

How is the driver added to the classpath ? Through @Grab ?

Cheers
Mario

2017-04-05 20:28 GMT+02:00 Imholz, John J. <imholzj@musc.edu<mailto:imholzj@musc.edu>>:
This message was sent securely by MUSC<http://www.musc.edu/>


In Groovy Console “Class” seems to find the Driver, but “Sql” does not?  What am I
misunderstanding?  (BTW, the connection string is what I’m using in the sqlline utility)

--- console ---
import java.sql.*
import groovy.sql.Sql

def d =  Class.forName('net.sourceforge.jtds.jdbc.Driver').newInstance()
println d.toString()

def sql = Sql.newInstance('jdbc:jtds:sybase://server.musc.edu:4100/mydb;tds=5.0<http://server.musc.edu:4100/mydb;tds=5.0>',
                          'user',
                          'password',
                          'net.sourceforge.jtds.jdbc.Driver'
                          )

--- output ---
jTDS 1.2.5
Exception thrown

java.lang.ClassNotFoundException: net.sourceforge.jtds.jdbc.Driver
                at java.net.URLClassLoader.findClass(URLClassLoader.java:381)
                at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
                at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:331)
                at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
                at java.lang.Class.forName0(Native Method)
                at java.lang.Class.forName(Class.java:264)
                at groovy.sql.Sql.loadDriver(Sql.java:705)
                at groovy.sql.Sql.newInstance(Sql.java:445)
                at groovy.sql.Sql$newInstance.call(Unknown Source)
                at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:48)
                at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:113)
                at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:149)
                at ConsoleScript61.run(ConsoleScript61:7)



-------------------------------------------------------------------------
This message was secured via TLS by MUSC<http://www.musc.edu>.





-------------------------------------------------------------------------
This message was secured via TLS by MUSC.
Mime
View raw message