groovy-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Mario Garcia <mario.g...@gmail.com>
Subject Re: Database Drivers
Date Fri, 07 Apr 2017 07:25:04 GMT
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>:

> 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',
>
>                           '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>*.

Mime
View raw message