Oracle.jdbc.OracleDriver

So I followed this guide:

And in addition I downloaded JDBC Thin driver from the Oracle database release from here:
http://www.oracle.com/technetwork/database/features/jdbc/default-2280470.html

Here’s the jars:

$ ls -l /Applications/oracle/product/instantclient_64/11.2.0.4.0/jdbc/lib
[email protected] 1 comlock  staff  2091135 Jan 28  2014 ojdbc5.jar
[email protected] 1 comlock  staff  2739616 Jan 28  2014 ojdbc6.jar
[email protected] 1 comlock  staff  3698857 May  5 10:51 ojdbc7.jar

Then I added

classpath fileTree('/Applications/oracle/product/instantclient_64/11.2.0.4.0/jdbc/lib')

To buildscript dependencies in build.gradle

And then I added this in a service.js

var DriverClass = Packages.oracle.jdbc.OracleDriver;

And I end up with this error:

java.lang.ClassNotFoundException: oracle.jdbc.OracleDriver

What am I doing wrong?

Caveat: I’m not a java programmer.

Or should I download something like:
http://www.java2s.com/Code/Jar/j/Downloadjdbcoraclejar.htm

This gives me the same error:

java.lang.Class.forName('oracle.jdbc.OracleDriver');

Got idea from: http://stackoverflow.com/questions/24280423/how-to-specify-the-classpath-for-for-jjs-nashorn-javascript

I added the below to dependencies (not under buildscript) in build.gradle

include "com.oracle.jdbc:com.springsource.oracle.jdbc:10.2.0.2"

And did

$ ./gradlew clean deploy

No more error :slight_smile:

Now I gotta see If can make that db connection.

Yes I was able to connect and do SELECT COUNT(*)…

2 Likes

Glad you figured it out. include scope is actually including the jdbc drinver into the app and should be the right approach. We have plans for creating a lib-sql in the future which will have a good tuturial on how to connect to sql databases.

Hi again.

You could try out lib-sql (https://github.com/enonic/lib-sql). Just released the first version 0.5.0 that you could try out.

1 Like