I'm trying to get started with DbFit 4.0.0 as described in Getting Started guide.
I have the following test http://localhost:8085/HelloWorldTest
!path lib/*.jar
!|dbfit.OracleTest|
!|Connect|localhost:1521|integration|integration|XEPDB1|
!|Query| select 'test' as x from dual|
|x|
|test|
But when I run the test I'm getting the following problem:
java.lang.Error: Cannot load Oracle database driver oracle.jdbc.OracleDriver. Is the JDBC driver on the classpath?
at dbfit.api.DbEnvironmentFactory$EnvironmentDescriptor.checkDriver(DbEnvironmentFactory.java:45)
at dbfit.api.DbEnvironmentFactory$EnvironmentDescriptor.createEnvironmentInstance(DbEnvironmentFactory.java:60)
at dbfit.api.DbEnvironmentFactory.createEnvironmentInstance(DbEnvironmentFactory.java:102)
at dbfit.api.DbEnvironmentFactory.newEnvironmentInstance(DbEnvironmentFactory.java:106)
at dbfit.OracleTest.(OracleTest.java:5)
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
at java.lang.Class.newInstance(Class.java:442)
at fit.FixtureClass.newInstance(FixtureClass.java:24)
at fit.FixtureLoader.instantiateFixture(FixtureLoader.java:61)
at fit.FixtureLoader.instantiateFirstValidFixtureClass(FixtureLoader.java:82)
at fit.FixtureLoader.disgraceThenLoad(FixtureLoader.java:43)
at fit.Fixture.loadFixture(Fixture.java:142)
at fit.Fixture.getLinkedFixtureWithArgs(Fixture.java:134)
at fit.Fixture.doTables(Fixture.java:79)
at fit.FitServer.process(FitServer.java:81)
at fit.FitServer.run(FitServer.java:56)
at fit.FitServer.main(FitServer.java:41)
Caused by: java.lang.ClassNotFoundException: oracle.jdbc.OracleDriver
at java.net.URLClassLoader.findClass(URLClassLoader.java:387)
at java.lang.ClassLoader.loadClass(ClassLoader.java:418)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:352)
at java.lang.ClassLoader.loadClass(ClassLoader.java:351)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:264)
at dbfit.api.DbEnvironmentFactory$EnvironmentDescriptor.checkDriver(DbEnvironmentFactory.java:43)
... 19 more
I find nothing relevant from:
- https://dbfit.github.io/dbfit/docs/database-specific-information.html
- https://dbfit.github.io/dbfit/docs/reference.html#connect
I'm running DbFit in Linux (Lubuntu 22.04 LTS).
I had to solve the following two problems before I got the example running:
Problem #1 missing Oracle JDBC driver
I downloaded Oracle JDBC driver (
ojdbc8.jar) from the Oracle download page:https://www.oracle.com/database/technologies/appdev/jdbc-downloads.html
and copied it to
<DBFIT_HOME>/lib.Unfortunately after that I run into the second problem.
Problem #2 incorrect connection string
Now I got the following error:
My connection string:
should be correct and I can connect to the database with other tools.
After a bit of tinkering I got the following connection string working:
In general the connection string format is:
See e.g. URL string format for connecting to Oracle database with JDBC
Working test
Complete working getting started test: http://localhost:8085/HelloWorldTest