How do I load the Oracle driver from the local file system? This should be simple, but gradle is turning this into a multi-hour task.
The following doesn’t work because it doesn’t know find the ojdbc-14.jar file in the lib/ directory:
repositories {
flatDir name: ‘localRepository’, dirs: ‘lib’ }
configurations {
driver }
task loadOracle() << {
URLClassLoader loader = GroovyObject.class.classLoader
configurations.driver.each {File file ->
loader.addURL(file.toURL())
println file.toURL()
}
//Class driverClass = loader.loadClass(‘oracle.jdbc.OracleDriver’)
Thread.currentThread().getContextClassLoader().loadClass(‘oracle.jdbc.OracleDriver’)
java.sql.Driver driverInstance = driverClass.newInstance()
java.sql.DriverManager.registerDriver(driverInstance)
//
Sql sql = Sql.newInstance(‘jdbc-url’,‘username’,‘password’) }