I'm trying to do some Sql stuff and added
>import groovy.sql.Sql
but when I try to use the Sql class with a line like the following in a
gradle task
>sql =
Sql.newInstance("jdbc:oracle:thin:@srv:1521:database","usr","pswrd","oracle.jdbc.OracleDriver")
I get a 'Class Not Found Exception'.
To resolve the drive dependencies I added the following lines at the
beginning of the build.gradle script:
>buildscript {
> repositories {
> flatDir name: 'localRepository', dirs: 'lib'
> }
> dependencies {
> classpath name: 'ojdbc14'
> }
>}
and put the oracle driver 'ojdbc14.jar' into the directory '$rootDir/lib'
which seems to be correctly resolved.
Even with these lines the driver class is not found.
Also other attempts to advice the DriverManager to register the oracle
driver like
> Class.forName("oracle.jdbc.OracleDriver")
do not work, although the driver can be instanciated like this:
> def oracleDriver = new oracle.jdbc.OracleDriver()
> println "hello jdbc: " + oracleDriver.toString()
> java.sql.DriverManager.registerDriver ( oracleDriver )
Registration seems not to be successful, since
> java.sql.DriverManager.getDrivers().each { println "Driver: " + it.name }
does not respond anything.
I think, that there is a problem with the classLoader but can't figure out,
what!
Can anybody help?
--
View this message in context:
http://www.nabble.com/using-jdbc-driver-in-a-task-fails-tp25752010p25752010.html
Sent from the gradle-user mailing list archive at Nabble.com.
---------------------------------------------------------------------
To unsubscribe from this list, please visit:
http://xircles.codehaus.org/manage_email