Getting Error while connecting to Oracle DB

Hello Everyone,

I am trying to run the lein run with user profile including all drivers.I already built all the drivers and they are in my plugins directory. Everything seemed fine but when I try to connect to oracle DB nothing happens and am getting this error .

Please help.

Thanks in Advance,
Kaustav Banerjee

Hi @kaustav1996
Which version of ojdbc are you using?
Please post the output of the follow commands:

# OS and version
 sed -nE 's/^PRETTY_NAME="([^"]+)"$/\1/p' /etc/os-release
# Git branch and commit
 echo `git status | head -1 && git log -1 --format="commit %H"`
# Java version and architecture
 java -version
# Java variable configuration
 echo $JAVA_HOME
# Java path configuration
 echo $PATH | grep --color=never -oe "/usr/lib/jvm/[^:]*"
# Lein version
 lein --version
# NodeJS version
 nodejs --version
# Yarn version
 yarn --version

tsecl@tsecl-ubuntu:~$ sed -nE ‘s/^PRETTY_NAME="([^"]+)"$/\1/p’ /etc/os-release
Ubuntu 16.04.6 LTS
tsecl@tsecl-ubuntu:~$ cd metabase
tsecl@tsecl-ubuntu:~/metabase$ echo git status | head -1 && git log -1 --format="commit %H"
On branch master commit 1f48cf5e27fdb3d3edbc4ef49a7ecc4c2728b665
tsecl@tsecl-ubuntu:~/metabase$ java -version
openjdk version “1.8.0_242”
OpenJDK Runtime Environment (build 1.8.0_242-8u242-b08-0ubuntu3~16.04-b08)
OpenJDK 64-Bit Server VM (build 25.242-b08, mixed mode)
tsecl@tsecl-ubuntu:~/metabase$ echo $JAVA_HOME

tsecl@tsecl-ubuntu:~/metabase$ lein --version
Leiningen 2.9.3 on Java 1.8.0_242 OpenJDK 64-Bit Server VM
tsecl@tsecl-ubuntu:~/metabase$ nodejs --version
v10.19.0
tsecl@tsecl-ubuntu:~/metabase$ yarn --version
1.22.4
tsecl@tsecl-ubuntu:~/metabase$ echo $PATH | grep --color=never -oe “/usr/lib/jvm/[^:]*”

@kaustav1996
Which version of ojdbc are you using?
And you haven’t installed Java correctly, since it’s not showing $JAVA_HOME or $PATH

I am using ojdbc8. Java and Javac are working but the paths are not there. Shall I set them?

@kaustav1996 But which version specifically? https://www.metabase.com/docs/latest/administration-guide/databases/oracle.html
Yes, you need to set the paths.

This one : Oracle Database 12.2.0.1 JDBC Driver

Ok trying to set the path first. then will do the entire process again. Also changing my java version from openjdk to oracle jdk.

@kaustav1996 Okay, also try ojdbc8.jar version 19c instead.

tsecl@tsecl-ubuntu:~$ echo $PATH | grep --color=never -oe ‘/usr/lib/jvm/[^:]*’
/usr/lib/jvm/jdk1.8.0_241/bin
tsecl@tsecl-ubuntu:~$ echo $JAVA_HOME
/usr/lib/jvm/jdk1.8.0_241

my oracle database is oracle 12c 12.2.0.1 . should i still use the one u recommended?

@kaustav1996 Almost every problem there has been with Oracle the past few months has been fixed by using 19c.

So are you sure this wont cause any extra issue while I try to connect to my oracle 12c database? I thought I should download the server for the db am using.

@kaustav1996 I don’t know. Try.

Same issue once again. I am using the master branch . shall I use an older 0.34 release branch?

03-18 23:37:26 INFO driver.impl :: Initializing driver :oracle…
03-18 23:37:26 INFO plugins.classloader :: Added URL file:/home/tsecl/metabase/plugins/oracle.metabase-driver.jar to classpath
03-18 23:37:26 DEBUG plugins.init-steps :: Loading plugin namespace metabase.driver.oracle…
03-18 23:37:26 INFO driver.impl :: Registered driver :oracle (parents: [:sql-jdbc]) :truck:
03-18 23:37:26 DEBUG plugins.jdbc-proxy :: Registering JDBC proxy driver for class oracle.jdbc.OracleDriver…
03-18 23:37:26 DEBUG plugins.jdbc-proxy :: Deregistering original JDBC driver oracle.jdbc.OracleDriver@46439782…
Load lazy loading driver :oracle took 351.3 ms
03-18 23:37:26 ERROR driver.util :: Database connection error
java.lang.ExceptionInInitializerError
at oracle.net.nt.NetStatImpl.incrementBytesSent(NetStatImpl.java:73)
at oracle.net.nt.TimeoutSocketChannel.write(TimeoutSocketChannel.java:205)
at oracle.net.ns.NIOPacket.writeToSocketChannel(NIOPacket.java:350)
at oracle.net.ns.NIOConnectPacket.writeToSocketChannel(NIOConnectPacket.java:247)
at oracle.net.ns.NSProtocolNIO.negotiateConnection(NSProtocolNIO.java:117)
at oracle.net.ns.NSProtocol.connect(NSProtocol.java:340)
at oracle.jdbc.driver.T4CConnection.connect(T4CConnection.java:1596)
at oracle.jdbc.driver.T4CConnection.logon(T4CConnection.java:588)
at oracle.jdbc.driver.PhysicalConnection.connect(PhysicalConnection.java:793)
at oracle.jdbc.driver.T4CDriverExtension.getConnection(T4CDriverExtension.java:57)
at oracle.jdbc.driver.OracleDriver.connect(OracleDriver.java:747)
at oracle.jdbc.driver.OracleDriver.connect(OracleDriver.java:562)
at metabase.plugins.jdbc_proxy$proxy_driver$reify__5593.connect(jdbc_proxy.clj:32)
at java.sql.DriverManager.getConnection(DriverManager.java:664)
at java.sql.DriverManager.getConnection(DriverManager.java:208)
at clojure.java.jdbc$get_driver_connection.invokeStatic(jdbc.clj:271)
at clojure.java.jdbc$get_driver_connection.invoke(jdbc.clj:250)
at clojure.java.jdbc$get_connection.invokeStatic(jdbc.clj:411)
at clojure.java.jdbc$get_connection.invoke(jdbc.clj:274)
at clojure.java.jdbc$db_query_with_resultset_STAR_.invokeStatic(jdbc.clj:1093)
at clojure.java.jdbc$db_query_with_resultset_STAR_.invoke(jdbc.clj:1075)
at clojure.java.jdbc$query.invokeStatic(jdbc.clj:1164)
at clojure.java.jdbc$query.invoke(jdbc.clj:1126)
at clojure.java.jdbc$query.invokeStatic(jdbc.clj:1142)
at clojure.java.jdbc$query.invoke(jdbc.clj:1126)
at metabase.driver.oracle$eval84128$fn__84129.invoke(oracle.clj:85)
at clojure.lang.MultiFn.invoke(MultiFn.java:234)
at metabase.driver.util$can_connect_with_details_QMARK_$fn__26131.invoke(util.clj:32)
at metabase.util$do_with_timeout$fn__5024.invoke(util.clj:301)
at clojure.core$binding_conveyor_fn$fn__5754.invoke(core.clj:2030)
at clojure.lang.AFn.call(AFn.java:18)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
at java.lang.Thread.run(Thread.java:748)
Caused by: java.lang.IllegalStateException: Timer already cancelled.
at java.util.Timer.sched(Timer.java:397)
at java.util.Timer.scheduleAtFixedRate(Timer.java:328)
at oracle.net.nt.Clock.(Clock.java:52)
… 35 more
03-18 23:37:26 DEBUG middleware.log :: POST /api/setup/validate 400 491.7 ms (0 DB calls)
{:errors {:dbname nil}}

03-18 23:37:26 ERROR driver.util :: Database connection error
java.lang.NoClassDefFoundError: Could not initialize class oracle.net.nt.Clock
at oracle.net.nt.NetStatImpl.incrementBytesSent(NetStatImpl.java:73)
at oracle.net.nt.TimeoutSocketChannel.write(TimeoutSocketChannel.java:205)
at oracle.net.ns.NIOPacket.writeToSocketChannel(NIOPacket.java:350)
at oracle.net.ns.NIOConnectPacket.writeToSocketChannel(NIOConnectPacket.java:247)
at oracle.net.ns.NSProtocolNIO.negotiateConnection(NSProtocolNIO.java:117)
at oracle.net.ns.NSProtocol.connect(NSProtocol.java:340)
at oracle.jdbc.driver.T4CConnection.connect(T4CConnection.java:1596)
at oracle.jdbc.driver.T4CConnection.logon(T4CConnection.java:588)
at oracle.jdbc.driver.PhysicalConnection.connect(PhysicalConnection.java:793)
at oracle.jdbc.driver.T4CDriverExtension.getConnection(T4CDriverExtension.java:57)
at oracle.jdbc.driver.OracleDriver.connect(OracleDriver.java:747)
at oracle.jdbc.driver.OracleDriver.connect(OracleDriver.java:562)
at metabase.plugins.jdbc_proxy$proxy_driver$reify__5593.connect(jdbc_proxy.clj:32)
at java.sql.DriverManager.getConnection(DriverManager.java:664)
at java.sql.DriverManager.getConnection(DriverManager.java:208)
at clojure.java.jdbc$get_driver_connection.invokeStatic(jdbc.clj:271)
at clojure.java.jdbc$get_driver_connection.invoke(jdbc.clj:250)
at clojure.java.jdbc$get_connection.invokeStatic(jdbc.clj:411)
at clojure.java.jdbc$get_connection.invoke(jdbc.clj:274)
at clojure.java.jdbc$db_query_with_resultset_STAR_.invokeStatic(jdbc.clj:1093)
at clojure.java.jdbc$db_query_with_resultset_STAR_.invoke(jdbc.clj:1075)
at clojure.java.jdbc$query.invokeStatic(jdbc.clj:1164)
at clojure.java.jdbc$query.invoke(jdbc.clj:1126)
at clojure.java.jdbc$query.invokeStatic(jdbc.clj:1142)
at clojure.java.jdbc$query.invoke(jdbc.clj:1126)
at metabase.driver.oracle$eval84128$fn__84129.invoke(oracle.clj:85)
at clojure.lang.MultiFn.invoke(MultiFn.java:234)
at metabase.driver.util$can_connect_with_details_QMARK_$fn__26131.invoke(util.clj:32)
at metabase.util$do_with_timeout$fn__5024.invoke(util.clj:301)
at clojure.core$binding_conveyor_fn$fn__5754.invoke(core.clj:2030)
at clojure.lang.AFn.call(AFn.java:18)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
at java.lang.Thread.run(Thread.java:748)
03-18 23:37:26 DEBUG middleware.log :: POST /api/setup/validate 400 9.8 ms (0 DB calls)
{:errors {:dbname “Could not initialize class oracle.net.nt.Clock”}}

@kaustav1996 I’ve never seen that error before, but it’s saying there’s a connection error, so are you sure there’s no firewalls/etc blocking?
Try running the release instead of your own build - that might help you debug the problem.

Update:

Downloaded the metabase.jar from the website and its working fine which means there is no DB connectivity issue. Used the 19c driver.

But I need to build it from source as I needed to make a small change in frontend. Can’t really understand why its not working when I am running from source using lein. I am including the drivers too .
I am running :

lein with-profiles +include-all-drivers run

Now I am gonna switch the branch to an older release like 0.34 and try.

Yaaaaaaayyy!!

Ran the metabase.jar from uberjar that was created while building the drivers from the project source dir and it worked. I literally have no idea why lein wasn’t working.

@kaustav1996 Use release-0.34.x - there are so many new things on master
You can just use lein ring server, which will also include all drivers.