Mark Chance commented on New Feature JENKINS-24274

Is this available anywhere? I don't see such a fork on GitHub...
I'm trying to do a very similar thing, but even less ambitious - have my Groovy script read from a database (hard-coded table, column, etc.). But it is not working due to class loader issues – i have a jar file with the sqlite driver in it, but I sure can't get it to be recognized by the Groovy...
import groovy.sql.Sql
//def jc = jenkins.getPluginManager().uberClassLoader;
def jc = this.getClass().getClassLoader()
def furl = new File("/vagrant/lib/sqlite-jdbc-3.8.7.jar").toURL()
jc.addURL(furl)
def cc = Class.forName('org.sqlite.JDBC', true, jc)
java.sql.DriverManager.registerDriver(cc.newInstance())
def props = new java.util.Properties()
def sql = new Sql(java.sql.DriverManager.getConnection('jdbc:sqlite:databasefile.sqlite', props))

Results in:
Failed to execute script
java.sql.SQLException: No suitable driver found for jdbc:sqlite:databasefile.sqlite
at java.sql.DriverManager.getConnection(DriverManager.java:596)
at java.sql.DriverManager.getConnection(DriverManager.java:187)
at java_sql_DriverManager$getConnection.call(Unknown Source)
at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:42)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:108)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:120)
at Script1.run(Script1.groovy:9)
at groovy.lang.GroovyShell.evaluate(GroovyShell.java:580)
at groovy.lang.GroovyShell.evaluate(GroovyShell.java:618)
at groovy.lang.GroovyShell.evaluate(GroovyShell.java:589)

This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators.
For more information on JIRA, see: http://www.atlassian.com/software/jira

--
You received this message because you are subscribed to the Google Groups "Jenkins Issues" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to