db-derby-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Steinar Bang ...@dod.no>
Subject Can the embedded JDBC driver and the client JDBC driver co-exist?
Date Sat, 12 Aug 2017 13:16:47 GMT
In my project[1] I am using a derby in-memory database with the embedded
driver for unit testing and integration testing.  I am using PostgreSQL
as the production server.

I am using Liquibase[2] to set up the schema for both Derby and
PostgreSQL, and I'm also using Liquibase to set up the test data in the
derby database.

What I wanted to do, was to dump the test database to a Derby network
server and do some tests on the data.  My changes worked fine in
PostgreSQL but not in the derby tests, and I wanted the chance to take a
look at them.

So what I did was add a pseudo unit test to a test class, that would
connect to "jdbc:derby://localhost:1527/ukelonn"[3].

When I tried running that test, it was unable to find the driver.

So I googled a bit more, and added a dependency to the derby client
jar in the test scope[4].

But then the unit test failed with the following error:
 java.lang.ClassCastException: org.apache.derby.jdbc.ClientDriver cannot be cast to org.apache.derby.jdbc.InternalDriver
	at org.apache.derby.jdbc.BasicEmbeddedDataSource40.findDriver(Unknown Source)
	at org.apache.derby.jdbc.EmbeddedConnectionPoolDataSource.createPooledConnection(Unknown
Source)
	at org.apache.derby.jdbc.EmbeddedConnectionPoolDataSource.getPooledConnection(Unknown Source)
	at no.priv.bang.ukelonn.bundle.db.test.UkelonnDatabaseProviderTest.addUkelonnSchemaAndDataToDerbyServer(UkelonnDatabaseProviderTest.java:296)

Are the problems caused by me having both the embedded driver and the
network driver loaded into the same java application (in this case: the
same JUnit test)?

If there is a conflict between the embedded JDBC driver and the client
JDBC driver, is there a way around the conflict, other than creating a
separate maven project just to upload the liquibase files?

Thanks!


- Steinar



References:
 [1] <https://github.com/steinarb/ukelonn>
 [2] <http://www.liquibase.org>
 [3] <https://github.com/steinarb/ukelonn/blob/scratch/derby-test-writing-to-network-server/ukelonn.bundle.db.test/src/test/java/no/priv/bang/ukelonn/bundle/db/test/UkelonnDatabaseProviderTest.java#L283>
 [4] <https://github.com/steinarb/ukelonn/commit/513d94690bd86cd42116190e2b58ce2a71fb80e6>



Mime
View raw message