You are viewing a plain text version of this content. The canonical link for it is here.
Posted to derby-user@db.apache.org by Russell Bateman <ru...@windofkeltia.com> on 2020/06/25 20:28:53 UTC
java.sql.SQLException: No suitable driver found for
jdbc:derby:memory:sampledb;create=true
I have very recent code that works in a JUnit test case.
@Test
public void test()
{
final String DATABASE = "jdbc:derby:memory:sampledb;create=true";
final String USERNAME = "sa";
final String PASSWORD = "sa";
final String CREATE_TABLE = "CREATE TABLE names ( oid INT
GENERATED ALWAYS AS IDENTITY, name VARCHAR( 20 ) )";
final String INSERT_NAME1 = "INSERT INTO names ( name ) VALUES (
'Jack' )";
final String QUERY = "SELECT oid, name FROM names";
Connection connection = null;
try
{
connection = DriverManager.getConnection( DATABASE, USERNAME,
PASSWORD );
Statement statement = connection.createStatement();
...
In /pom.xml/, I have the following:
<dependency>
<groupId>org.apache.derby</groupId>
<artifactId>*derby*</artifactId>
<version>10.15.2.0</version>
<scope>test</scope>
</dependency>
I only want to use Derby _in-memory_ backing some unit test cases that
need a database (not requiring a running server or dæmon, etc.). It all
works perfectly inside IntelliJ IDEA.
However, when I build from the command line (mvn clean package), I see
this and can find no solution:
java.sql.SQLException: No suitable driver found for
jdbc:derby:memory:sampledb;create=true
at java.sql.DriverManager.getConnection(DriverManager.java:689)
at java.sql.DriverManager.getConnection(DriverManager.java:247)
at
com.imatsolutions.database.ApacheDerbyTest.testDirectlyToDerby(ApacheDerbyTest.java:78)
In /pom.xml/, I have tried adding the following, and I have tried many
other solutions, some of which are supposed to be obsolete (
Class.for(...), DriverManager.registerDriver( ... ), etc. ), but cannot
find a happy solution.
<dependency>
<groupId>org.apache.derby</groupId>
<artifactId>*derbyclient*</artifactId>
<version>10.15.2.0</version>
<scope>test</scope>
</dependency>
Any comment would be welcome.
Thanks.
Re: java.sql.SQLException: No suitable driver found for
jdbc:derby:memory:sampledb;create=true
Posted by Davide Grandi <da...@email.it>.
Hello Russel,
as a maven addict I stumbled upon multiple java runtime ... too many times.
(release tag limit only your compiling classes, root cause is a java 8
running your pgms against a java9 derby lib).
In order to get repeatable builds I use (but it's a very personal
choice) maven toolchain
and NO java installed, only jdk "expanded" in folders.
So ant, maven & other java apps start with "their own" JAVA_HOME &|
java-bin in their path.
Either in win & linux machines.
Good luck & happy derby-ing.
davide
On 26/06/2020 22:22, Russell Bateman wrote:
> I'm using JDK 11, but it's true that I have the language options
> narrowed to Java 8 (lambda, type annotations, etc.). However, that's
> in IntelliJ IDEA. There's a sort of wall between how things are done
> up to Java 8 and how they're done in the world that comes after. It's
> time to cross that wall more definitively. For one thing, I added this
> to my root /pom.xml/. (I was using only
> <maven.compiler.source>1.8</maven.compiler.source>and
> <maven.compiler.target>1.8</maven.compiler.target>as properties in my
> root /pom.xml/ before this.)
>
> <plugin>
> <groupId>org.apache.maven.plugins</groupId>
> <artifactId>maven-compiler-plugin</artifactId>
> <version>3.8.1</version>
> <configuration>
> **<release>8</release><!-- notwithstanding the suggested Java 9
> requirement! -->
> </configuration>
> </plugin>
>
> And I added
>
> export JAVA_HOME=/home/russ/dev/jdk-11.0.2
>
> to /~/.profile/. (What I was using in IntelliJ IDEA already, but I was
> getting away without having JAVA_HOMEset at the command line until
> now. So I corrected that.)
>
> It appears that, for what little I am using in Derby, it is imperative
> to have only /derby/ as a dependency, but not /derbyshared/ or
> /derbytools/ (for what I'm trying to do, please see source code posted
> elsewhere in this thread).
>
> Many thanks to both Davide and Rick for helping me through this. It
> turned out not to be a Derby problem (as I suspected that it would
> not), but something to correct with Maven, a) careful dependencies and
> versions, b) not defaulting to my routinely installed JRE, and c) use
> of the /maven-compiler-plugin/ to tune Java compilation more carefully.
>
> I hope this helps someone else.
>
> Russ
>
> On 6/26/20 12:59 PM, Davide Grandi wrote:
>>
>> It seems to me that you're running test with java 8 ( 50 => 6, 51 =>
>> 7, 52 => 8, ...).
>>
>> But Derby requires java 9.
>>
>> Bye,
>>
>> Davide Grandi
>>
>> On 26/06/2020 17:11, Russell Bateman wrote:
>>> I get UnsupportedClassVersionErrorin each case. Here's what that
>>> looks like:
>>>
>>> testDirectlyToDerby(com.imatsolutions.database.ApacheDerbyTest)
>>> java.lang.UnsupportedClassVersionError:
>>> *org/apache/derby/impl/jdbc/EmbedConnection*has been compiled by
>>> a more recent version of the Java Runtime (class file version
>>> 53.0), this version of the Java Runtime only recognizes class
>>> file versions up to 52.0
>>> at java.lang.ClassLoader.defineClass1(Native Method)
>>> at java.lang.ClassLoader.defineClass(ClassLoader.java:756)
>>> at
>>> java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142)
>>> at java.net.URLClassLoader.defineClass(URLClassLoader.java:468)
>>> at java.net.URLClassLoader.access$100(URLClassLoader.java:74)
>>> at java.net.URLClassLoader$1.run(URLClassLoader.java:369)
>>> at java.net.URLClassLoader$1.run(URLClassLoader.java:363)
>>> at java.security.AccessController.doPrivileged(Native Method)
>>> at java.net.URLClassLoader.findClass(URLClassLoader.java:362)
>>> 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
>>> com.imatsolutions.database.ApacheDerbyTest.testDirectlyToDerby(ApacheDerbyTest.java:78)
>>>
>>> java.lang.UnsupportedClassVersionError:
>>> *org/apache/derby/shared/common/util/ArrayUtil*has been compiled
>>> by a more recent version of the Java Runtime (class file version
>>> 53.0), this version of the Java Runtime only recognizes class
>>> file versions up to 52.0
>>> ...
>>>
>>> java.lang.UnsupportedClassVersionError:
>>> *org/apache/derby/jdbc/BasicEmbeddedDataSource40*has been
>>> compiled by a more recent version of the Java Runtime (class
>>> file version 53.0), this version of the Java Runtime only
>>> recognizes class file versions up to 52.0
>>> ...
>>>
>>> Just in case there is an older version of Derby in there somewhere,
>>> command-line Maven reports:
>>>
>>> [echoproperties]
>>> maven.dependency.org.apache.derby.derby.jar.path=/home/russ/.m2/repository/org/apache/derby/derby/10.15.2.0/derby-10.15.2.0.jar
>>> [echoproperties]
>>> maven.dependency.org.apache.derby.derbyshared.jar.path=/home/russ/.m2/repository/org/apache/derby/derbyshared/10.15.2.0/derbyshared-10.15.2.0.jar
>>> [echoproperties]
>>> maven.dependency.org.apache.derby.derbytools.jar.path=/home/russ/.m2/repository/org/apache/derby/derbytools/10.15.2.0/derbytools-10.15.2.0.jar
>>> .
>>> .
>>> .
>>> [echoproperties]
>>> org.apache.derby\:derby\:jar=/home/russ/.m2/repository/org/apache/derby/derby/10.15.2.0/derby-10.15.2.0.jar
>>> [echoproperties]
>>> org.apache.derby\:derbyshared\:jar=/home/russ/.m2/repository/org/apache/derby/derbyshared/10.15.2.0/derbyshared-10.15.2.0.jar
>>> [echoproperties]
>>> org.apache.derby\:derbytools\:jar=/home/russ/.m2/repository/org/apache/derby/derbytools/10.15.2.0/derbytools-10.15.2.0.jar
>>>
>>> All of this works in IntelliJ IDEA, which itself reports this and
>>> doesn't get UnsupportedClassVersionErrorwhen I run this unit test:
>>>
>>> - External Libraries
>>> > Maven: org.apache.derby:derby:10.15.2.0
>>> > Maven: org.apache.derby:derbyshared:10.15.2.0
>>> > Maven: org.apache.derby:derbytools:10.15.2.0
>>>
>>> Again, thanks for looking at this.
>>>
>>> On 6/26/20 6:46 AM, Rick Hillegas wrote:
>>>> 1) Do you have a stack trace showing what class can't be resolved?
>>>>
>>>> 2) What happens if you do a Class.forName() on the following
>>>> classes, which live, respectively, in derby.jar, derbyshared.jar,
>>>> and derbytools.jar:
>>>>
>>>> org.apache.derby.impl.jdbc.EmbedConnection
>>>> org.apache.derby.shared.common.util.ArrayUtil
>>>> org.apache.derby.jdbc.BasicEmbeddedDataSource40
>>>>
>>>> Thanks,
>>>> -Rick
>>>>
>>>> On 6/25/20 4:20 PM, Russell Bateman wrote:
>>>>> Oops. I spoke too soon. I still had my JUnit tests @Ignore'd. It
>>>>> doesn't work yet. I still get "no suitable driver." I added
>>>>> derbytools too, but that made no difference. Further thoughts?
>>>>>
>>>>>
>>>>> On 6/25/20 5:01 PM, Russell Bateman wrote:
>>>>>> Thank you; that's very kind. It now works. (I'm not using
>>>>>> DataSources for now.) I greatly appreciate your help.
>>>>>>
>>>>>> Best regards,
>>>>>> Russ
>>>>>>
>>>>>> On 6/25/20 4:48 PM, Rick Hillegas wrote:
>>>>>>> The 10.15 family of releases introduced a JPMS modularization of
>>>>>>> Derby. That re-factored the code a bit. You will need to add
>>>>>>> derbyshared.jar to the classpath and build dependencies. If you
>>>>>>> are using DataSources, then you will also need to add
>>>>>>> derbytools.jar. Please see the detailed release note for
>>>>>>> DERBY-6945 on the 10.15.1.3 download page:
>>>>>>> http://db.apache.org/derby/releases/release-10.15.1.3.html
>>>>>>>
>>>>>>> Hope this helps,
>>>>>>> -Rick
>>>>>>>
>>>>>>> On 6/25/20 1:28 PM, Russell Bateman wrote:
>>>>>>>> I have very recent code that works in a JUnit test case.
>>>>>>>>
>>>>>>>> @Test
>>>>>>>> public void test()
>>>>>>>> {
>>>>>>>> final String DATABASE =
>>>>>>>> "jdbc:derby:memory:sampledb;create=true";
>>>>>>>> final String USERNAME = "sa";
>>>>>>>> final String PASSWORD = "sa";
>>>>>>>>
>>>>>>>> final String CREATE_TABLE = "CREATE TABLE names ( oid INT
>>>>>>>> GENERATED ALWAYS AS IDENTITY, name VARCHAR( 20 ) )";
>>>>>>>> final String INSERT_NAME1 = "INSERT INTO names ( name )
>>>>>>>> VALUES (
>>>>>>>> 'Jack' )";
>>>>>>>> final String QUERY = "SELECT oid, name FROM names";
>>>>>>>>
>>>>>>>> Connection connection = null;
>>>>>>>>
>>>>>>>> try
>>>>>>>> {
>>>>>>>> connection = DriverManager.getConnection( DATABASE,
>>>>>>>> USERNAME,
>>>>>>>> PASSWORD );
>>>>>>>>
>>>>>>>> Statement statement = connection.createStatement();
>>>>>>>> ...
>>>>>>>>
>>>>>>>> In /pom.xml/, I have the following:
>>>>>>>>
>>>>>>>> <dependency>
>>>>>>>> <groupId>org.apache.derby</groupId>
>>>>>>>> <artifactId>*derby*</artifactId>
>>>>>>>> <version>10.15.2.0</version>
>>>>>>>> <scope>test</scope>
>>>>>>>> </dependency>
>>>>>>>>
>>>>>>>> I only want to use Derby _in-memory_ backing some unit test
>>>>>>>> cases that need a database (not requiring a running server or
>>>>>>>> dæmon, etc.). It all works perfectly inside IntelliJ IDEA.
>>>>>>>>
>>>>>>>> However, when I build from the command line (mvn clean
>>>>>>>> package), I see this and can find no solution:
>>>>>>>>
>>>>>>>> java.sql.SQLException: No suitable driver found for
>>>>>>>> jdbc:derby:memory:sampledb;create=true
>>>>>>>> at
>>>>>>>> java.sql.DriverManager.getConnection(DriverManager.java:689)
>>>>>>>> at
>>>>>>>> java.sql.DriverManager.getConnection(DriverManager.java:247)
>>>>>>>> at
>>>>>>>> com.imatsolutions.database.ApacheDerbyTest.testDirectlyToDerby(ApacheDerbyTest.java:78)
>>>>>>>>
>>>>>>>>
>>>>>>>> In /pom.xml/, I have tried adding the following, and I have
>>>>>>>> tried many other solutions, some of which are supposed to be
>>>>>>>> obsolete ( Class.for(...), DriverManager.registerDriver( ... ),
>>>>>>>> etc. ), but cannot find a happy solution.
>>>>>>>>
>>>>>>>> <dependency>
>>>>>>>> <groupId>org.apache.derby</groupId>
>>>>>>>> <artifactId>*derbyclient*</artifactId>
>>>>>>>> <version>10.15.2.0</version>
>>>>>>>> <scope>test</scope>
>>>>>>>> </dependency>
>>>>>>>>
>>>>>>>> Any comment would be welcome.
>>>>>>>>
>>>>>>>> Thanks.
--
Ing. Davide Grandi
email : davide.grandi@email.it
mobile : +39 339 7468 778
linkedin : http://linkedin.com/in/davidegrandi
Re: java.sql.SQLException: No suitable driver found for
jdbc:derby:memory:sampledb;create=true
Posted by Russell Bateman <ru...@windofkeltia.com>.
I'm using JDK 11, but it's true that I have the language options
narrowed to Java 8 (lambda, type annotations, etc.). However, that's in
IntelliJ IDEA. There's a sort of wall between how things are done up to
Java 8 and how they're done in the world that comes after. It's time to
cross that wall more definitively. For one thing, I added this to my
root /pom.xml/. (I was using only
<maven.compiler.source>1.8</maven.compiler.source>and
<maven.compiler.target>1.8</maven.compiler.target>as properties in my
root /pom.xml/ before this.)
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.1</version>
<configuration>
**<release>8</release><!-- notwithstanding the suggested Java 9
requirement! -->
</configuration>
</plugin>
And I added
export JAVA_HOME=/home/russ/dev/jdk-11.0.2
to /~/.profile/. (What I was using in IntelliJ IDEA already, but I was
getting away without having JAVA_HOMEset at the command line until now.
So I corrected that.)
It appears that, for what little I am using in Derby, it is imperative
to have only /derby/ as a dependency, but not /derbyshared/ or
/derbytools/ (for what I'm trying to do, please see source code posted
elsewhere in this thread).
Many thanks to both Davide and Rick for helping me through this. It
turned out not to be a Derby problem (as I suspected that it would not),
but something to correct with Maven, a) careful dependencies and
versions, b) not defaulting to my routinely installed JRE, and c) use of
the /maven-compiler-plugin/ to tune Java compilation more carefully.
I hope this helps someone else.
Russ
On 6/26/20 12:59 PM, Davide Grandi wrote:
>
> It seems to me that you're running test with java 8 ( 50 => 6, 51 =>
> 7, 52 => 8, ...).
>
> But Derby requires java 9.
>
> Bye,
>
> Davide Grandi
>
> On 26/06/2020 17:11, Russell Bateman wrote:
>> I get UnsupportedClassVersionErrorin each case. Here's what that
>> looks like:
>>
>> testDirectlyToDerby(com.imatsolutions.database.ApacheDerbyTest)
>> java.lang.UnsupportedClassVersionError:
>> *org/apache/derby/impl/jdbc/EmbedConnection*has been compiled by
>> a more recent version of the Java Runtime (class file version
>> 53.0), this version of the Java Runtime only recognizes class
>> file versions up to 52.0
>> at java.lang.ClassLoader.defineClass1(Native Method)
>> at java.lang.ClassLoader.defineClass(ClassLoader.java:756)
>> at
>> java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142)
>> at java.net.URLClassLoader.defineClass(URLClassLoader.java:468)
>> at java.net.URLClassLoader.access$100(URLClassLoader.java:74)
>> at java.net.URLClassLoader$1.run(URLClassLoader.java:369)
>> at java.net.URLClassLoader$1.run(URLClassLoader.java:363)
>> at java.security.AccessController.doPrivileged(Native Method)
>> at java.net.URLClassLoader.findClass(URLClassLoader.java:362)
>> 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
>> com.imatsolutions.database.ApacheDerbyTest.testDirectlyToDerby(ApacheDerbyTest.java:78)
>>
>> java.lang.UnsupportedClassVersionError:
>> *org/apache/derby/shared/common/util/ArrayUtil*has been compiled
>> by a more recent version of the Java Runtime (class file version
>> 53.0), this version of the Java Runtime only recognizes class
>> file versions up to 52.0
>> ...
>>
>> java.lang.UnsupportedClassVersionError:
>> *org/apache/derby/jdbc/BasicEmbeddedDataSource40*has been
>> compiled by a more recent version of the Java Runtime (class file
>> version 53.0), this version of the Java Runtime only recognizes
>> class file versions up to 52.0
>> ...
>>
>> Just in case there is an older version of Derby in there somewhere,
>> command-line Maven reports:
>>
>> [echoproperties]
>> maven.dependency.org.apache.derby.derby.jar.path=/home/russ/.m2/repository/org/apache/derby/derby/10.15.2.0/derby-10.15.2.0.jar
>> [echoproperties]
>> maven.dependency.org.apache.derby.derbyshared.jar.path=/home/russ/.m2/repository/org/apache/derby/derbyshared/10.15.2.0/derbyshared-10.15.2.0.jar
>> [echoproperties]
>> maven.dependency.org.apache.derby.derbytools.jar.path=/home/russ/.m2/repository/org/apache/derby/derbytools/10.15.2.0/derbytools-10.15.2.0.jar
>> .
>> .
>> .
>> [echoproperties]
>> org.apache.derby\:derby\:jar=/home/russ/.m2/repository/org/apache/derby/derby/10.15.2.0/derby-10.15.2.0.jar
>> [echoproperties]
>> org.apache.derby\:derbyshared\:jar=/home/russ/.m2/repository/org/apache/derby/derbyshared/10.15.2.0/derbyshared-10.15.2.0.jar
>> [echoproperties]
>> org.apache.derby\:derbytools\:jar=/home/russ/.m2/repository/org/apache/derby/derbytools/10.15.2.0/derbytools-10.15.2.0.jar
>>
>> All of this works in IntelliJ IDEA, which itself reports this and
>> doesn't get UnsupportedClassVersionErrorwhen I run this unit test:
>>
>> - External Libraries
>> > Maven: org.apache.derby:derby:10.15.2.0
>> > Maven: org.apache.derby:derbyshared:10.15.2.0
>> > Maven: org.apache.derby:derbytools:10.15.2.0
>>
>> Again, thanks for looking at this.
>>
>> On 6/26/20 6:46 AM, Rick Hillegas wrote:
>>> 1) Do you have a stack trace showing what class can't be resolved?
>>>
>>> 2) What happens if you do a Class.forName() on the following
>>> classes, which live, respectively, in derby.jar, derbyshared.jar,
>>> and derbytools.jar:
>>>
>>> org.apache.derby.impl.jdbc.EmbedConnection
>>> org.apache.derby.shared.common.util.ArrayUtil
>>> org.apache.derby.jdbc.BasicEmbeddedDataSource40
>>>
>>> Thanks,
>>> -Rick
>>>
>>> On 6/25/20 4:20 PM, Russell Bateman wrote:
>>>> Oops. I spoke too soon. I still had my JUnit tests @Ignore'd. It
>>>> doesn't work yet. I still get "no suitable driver." I added
>>>> derbytools too, but that made no difference. Further thoughts?
>>>>
>>>>
>>>> On 6/25/20 5:01 PM, Russell Bateman wrote:
>>>>> Thank you; that's very kind. It now works. (I'm not using
>>>>> DataSources for now.) I greatly appreciate your help.
>>>>>
>>>>> Best regards,
>>>>> Russ
>>>>>
>>>>> On 6/25/20 4:48 PM, Rick Hillegas wrote:
>>>>>> The 10.15 family of releases introduced a JPMS modularization of
>>>>>> Derby. That re-factored the code a bit. You will need to add
>>>>>> derbyshared.jar to the classpath and build dependencies. If you
>>>>>> are using DataSources, then you will also need to add
>>>>>> derbytools.jar. Please see the detailed release note for
>>>>>> DERBY-6945 on the 10.15.1.3 download page:
>>>>>> http://db.apache.org/derby/releases/release-10.15.1.3.html
>>>>>>
>>>>>> Hope this helps,
>>>>>> -Rick
>>>>>>
>>>>>> On 6/25/20 1:28 PM, Russell Bateman wrote:
>>>>>>> I have very recent code that works in a JUnit test case.
>>>>>>>
>>>>>>> @Test
>>>>>>> public void test()
>>>>>>> {
>>>>>>> final String DATABASE =
>>>>>>> "jdbc:derby:memory:sampledb;create=true";
>>>>>>> final String USERNAME = "sa";
>>>>>>> final String PASSWORD = "sa";
>>>>>>>
>>>>>>> final String CREATE_TABLE = "CREATE TABLE names ( oid INT
>>>>>>> GENERATED ALWAYS AS IDENTITY, name VARCHAR( 20 ) )";
>>>>>>> final String INSERT_NAME1 = "INSERT INTO names ( name )
>>>>>>> VALUES (
>>>>>>> 'Jack' )";
>>>>>>> final String QUERY = "SELECT oid, name FROM names";
>>>>>>>
>>>>>>> Connection connection = null;
>>>>>>>
>>>>>>> try
>>>>>>> {
>>>>>>> connection = DriverManager.getConnection( DATABASE,
>>>>>>> USERNAME,
>>>>>>> PASSWORD );
>>>>>>>
>>>>>>> Statement statement = connection.createStatement();
>>>>>>> ...
>>>>>>>
>>>>>>> In /pom.xml/, I have the following:
>>>>>>>
>>>>>>> <dependency>
>>>>>>> <groupId>org.apache.derby</groupId>
>>>>>>> <artifactId>*derby*</artifactId>
>>>>>>> <version>10.15.2.0</version>
>>>>>>> <scope>test</scope>
>>>>>>> </dependency>
>>>>>>>
>>>>>>> I only want to use Derby _in-memory_ backing some unit test
>>>>>>> cases that need a database (not requiring a running server or
>>>>>>> dæmon, etc.). It all works perfectly inside IntelliJ IDEA.
>>>>>>>
>>>>>>> However, when I build from the command line (mvn clean package),
>>>>>>> I see this and can find no solution:
>>>>>>>
>>>>>>> java.sql.SQLException: No suitable driver found for
>>>>>>> jdbc:derby:memory:sampledb;create=true
>>>>>>> at
>>>>>>> java.sql.DriverManager.getConnection(DriverManager.java:689)
>>>>>>> at
>>>>>>> java.sql.DriverManager.getConnection(DriverManager.java:247)
>>>>>>> at
>>>>>>> com.imatsolutions.database.ApacheDerbyTest.testDirectlyToDerby(ApacheDerbyTest.java:78)
>>>>>>>
>>>>>>>
>>>>>>> In /pom.xml/, I have tried adding the following, and I have
>>>>>>> tried many other solutions, some of which are supposed to be
>>>>>>> obsolete ( Class.for(...), DriverManager.registerDriver( ... ),
>>>>>>> etc. ), but cannot find a happy solution.
>>>>>>>
>>>>>>> <dependency>
>>>>>>> <groupId>org.apache.derby</groupId>
>>>>>>> <artifactId>*derbyclient*</artifactId>
>>>>>>> <version>10.15.2.0</version>
>>>>>>> <scope>test</scope>
>>>>>>> </dependency>
>>>>>>>
>>>>>>> Any comment would be welcome.
>>>>>>>
>>>>>>> Thanks.
> --
> Ing. Davide Grandi
> email :davide.grandi@email.it
> mobile : +39 339 7468 778
> linkedin :http://linkedin.com/in/davidegrandi
Re: java.sql.SQLException: No suitable driver found for
jdbc:derby:memory:sampledb;create=true
Posted by Davide Grandi <da...@email.it>.
It seems to me that you're running test with java 8 ( 50 => 6, 51 => 7,
52 => 8, ...).
But Derby requires java 9.
Bye,
Davide Grandi
On 26/06/2020 17:11, Russell Bateman wrote:
> I get UnsupportedClassVersionErrorin each case. Here's what that looks
> like:
>
> testDirectlyToDerby(com.imatsolutions.database.ApacheDerbyTest)
> java.lang.UnsupportedClassVersionError:
> *org/apache/derby/impl/jdbc/EmbedConnection*has been compiled by a
> more recent version of the Java Runtime (class file version 53.0),
> this version of the Java Runtime only recognizes class file
> versions up to 52.0
> at java.lang.ClassLoader.defineClass1(Native Method)
> at java.lang.ClassLoader.defineClass(ClassLoader.java:756)
> at
> java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142)
> at java.net.URLClassLoader.defineClass(URLClassLoader.java:468)
> at java.net.URLClassLoader.access$100(URLClassLoader.java:74)
> at java.net.URLClassLoader$1.run(URLClassLoader.java:369)
> at java.net.URLClassLoader$1.run(URLClassLoader.java:363)
> at java.security.AccessController.doPrivileged(Native Method)
> at java.net.URLClassLoader.findClass(URLClassLoader.java:362)
> 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
> com.imatsolutions.database.ApacheDerbyTest.testDirectlyToDerby(ApacheDerbyTest.java:78)
>
> java.lang.UnsupportedClassVersionError:
> *org/apache/derby/shared/common/util/ArrayUtil*has been compiled
> by a more recent version of the Java Runtime (class file version
> 53.0), this version of the Java Runtime only recognizes class file
> versions up to 52.0
> ...
>
> java.lang.UnsupportedClassVersionError:
> *org/apache/derby/jdbc/BasicEmbeddedDataSource40*has been compiled
> by a more recent version of the Java Runtime (class file version
> 53.0), this version of the Java Runtime only recognizes class file
> versions up to 52.0
> ...
>
> Just in case there is an older version of Derby in there somewhere,
> command-line Maven reports:
>
> [echoproperties]
> maven.dependency.org.apache.derby.derby.jar.path=/home/russ/.m2/repository/org/apache/derby/derby/10.15.2.0/derby-10.15.2.0.jar
> [echoproperties]
> maven.dependency.org.apache.derby.derbyshared.jar.path=/home/russ/.m2/repository/org/apache/derby/derbyshared/10.15.2.0/derbyshared-10.15.2.0.jar
> [echoproperties]
> maven.dependency.org.apache.derby.derbytools.jar.path=/home/russ/.m2/repository/org/apache/derby/derbytools/10.15.2.0/derbytools-10.15.2.0.jar
> .
> .
> .
> [echoproperties]
> org.apache.derby\:derby\:jar=/home/russ/.m2/repository/org/apache/derby/derby/10.15.2.0/derby-10.15.2.0.jar
> [echoproperties]
> org.apache.derby\:derbyshared\:jar=/home/russ/.m2/repository/org/apache/derby/derbyshared/10.15.2.0/derbyshared-10.15.2.0.jar
> [echoproperties]
> org.apache.derby\:derbytools\:jar=/home/russ/.m2/repository/org/apache/derby/derbytools/10.15.2.0/derbytools-10.15.2.0.jar
>
> All of this works in IntelliJ IDEA, which itself reports this and
> doesn't get UnsupportedClassVersionErrorwhen I run this unit test:
>
> - External Libraries
> > Maven: org.apache.derby:derby:10.15.2.0
> > Maven: org.apache.derby:derbyshared:10.15.2.0
> > Maven: org.apache.derby:derbytools:10.15.2.0
>
> Again, thanks for looking at this.
>
> On 6/26/20 6:46 AM, Rick Hillegas wrote:
>> 1) Do you have a stack trace showing what class can't be resolved?
>>
>> 2) What happens if you do a Class.forName() on the following classes,
>> which live, respectively, in derby.jar, derbyshared.jar, and
>> derbytools.jar:
>>
>> org.apache.derby.impl.jdbc.EmbedConnection
>> org.apache.derby.shared.common.util.ArrayUtil
>> org.apache.derby.jdbc.BasicEmbeddedDataSource40
>>
>> Thanks,
>> -Rick
>>
>> On 6/25/20 4:20 PM, Russell Bateman wrote:
>>> Oops. I spoke too soon. I still had my JUnit tests @Ignore'd. It
>>> doesn't work yet. I still get "no suitable driver." I added
>>> derbytools too, but that made no difference. Further thoughts?
>>>
>>>
>>> On 6/25/20 5:01 PM, Russell Bateman wrote:
>>>> Thank you; that's very kind. It now works. (I'm not using
>>>> DataSources for now.) I greatly appreciate your help.
>>>>
>>>> Best regards,
>>>> Russ
>>>>
>>>> On 6/25/20 4:48 PM, Rick Hillegas wrote:
>>>>> The 10.15 family of releases introduced a JPMS modularization of
>>>>> Derby. That re-factored the code a bit. You will need to add
>>>>> derbyshared.jar to the classpath and build dependencies. If you
>>>>> are using DataSources, then you will also need to add
>>>>> derbytools.jar. Please see the detailed release note for
>>>>> DERBY-6945 on the 10.15.1.3 download page:
>>>>> http://db.apache.org/derby/releases/release-10.15.1.3.html
>>>>>
>>>>> Hope this helps,
>>>>> -Rick
>>>>>
>>>>> On 6/25/20 1:28 PM, Russell Bateman wrote:
>>>>>> I have very recent code that works in a JUnit test case.
>>>>>>
>>>>>> @Test
>>>>>> public void test()
>>>>>> {
>>>>>> final String DATABASE =
>>>>>> "jdbc:derby:memory:sampledb;create=true";
>>>>>> final String USERNAME = "sa";
>>>>>> final String PASSWORD = "sa";
>>>>>>
>>>>>> final String CREATE_TABLE = "CREATE TABLE names ( oid INT
>>>>>> GENERATED ALWAYS AS IDENTITY, name VARCHAR( 20 ) )";
>>>>>> final String INSERT_NAME1 = "INSERT INTO names ( name )
>>>>>> VALUES (
>>>>>> 'Jack' )";
>>>>>> final String QUERY = "SELECT oid, name FROM names";
>>>>>>
>>>>>> Connection connection = null;
>>>>>>
>>>>>> try
>>>>>> {
>>>>>> connection = DriverManager.getConnection( DATABASE,
>>>>>> USERNAME,
>>>>>> PASSWORD );
>>>>>>
>>>>>> Statement statement = connection.createStatement();
>>>>>> ...
>>>>>>
>>>>>> In /pom.xml/, I have the following:
>>>>>>
>>>>>> <dependency>
>>>>>> <groupId>org.apache.derby</groupId>
>>>>>> <artifactId>*derby*</artifactId>
>>>>>> <version>10.15.2.0</version>
>>>>>> <scope>test</scope>
>>>>>> </dependency>
>>>>>>
>>>>>> I only want to use Derby _in-memory_ backing some unit test cases
>>>>>> that need a database (not requiring a running server or dæmon,
>>>>>> etc.). It all works perfectly inside IntelliJ IDEA.
>>>>>>
>>>>>> However, when I build from the command line (mvn clean package),
>>>>>> I see this and can find no solution:
>>>>>>
>>>>>> java.sql.SQLException: No suitable driver found for
>>>>>> jdbc:derby:memory:sampledb;create=true
>>>>>> at
>>>>>> java.sql.DriverManager.getConnection(DriverManager.java:689)
>>>>>> at
>>>>>> java.sql.DriverManager.getConnection(DriverManager.java:247)
>>>>>> at
>>>>>> com.imatsolutions.database.ApacheDerbyTest.testDirectlyToDerby(ApacheDerbyTest.java:78)
>>>>>>
>>>>>>
>>>>>> In /pom.xml/, I have tried adding the following, and I have tried
>>>>>> many other solutions, some of which are supposed to be obsolete (
>>>>>> Class.for(...), DriverManager.registerDriver( ... ), etc. ), but
>>>>>> cannot find a happy solution.
>>>>>>
>>>>>> <dependency>
>>>>>> <groupId>org.apache.derby</groupId>
>>>>>> <artifactId>*derbyclient*</artifactId>
>>>>>> <version>10.15.2.0</version>
>>>>>> <scope>test</scope>
>>>>>> </dependency>
>>>>>>
>>>>>> Any comment would be welcome.
>>>>>>
>>>>>> Thanks.
--
Ing. Davide Grandi
email : davide.grandi@email.it
mobile : +39 339 7468 778
linkedin : http://linkedin.com/in/davidegrandi
Re: java.sql.SQLException: No suitable driver found for
jdbc:derby:memory:sampledb;create=true
Posted by Russell Bateman <ru...@windofkeltia.com>.
I get UnsupportedClassVersionErrorin each case. Here's what that looks like:
testDirectlyToDerby(com.imatsolutions.database.ApacheDerbyTest)
java.lang.UnsupportedClassVersionError:
*org/apache/derby/impl/jdbc/EmbedConnection* has been compiled by a
more recent version of the Java Runtime (class file version 53.0),
this version of the Java Runtime only recognizes class file versions
up to 52.0
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClass(ClassLoader.java:756)
at
java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142)
at java.net.URLClassLoader.defineClass(URLClassLoader.java:468)
at java.net.URLClassLoader.access$100(URLClassLoader.java:74)
at java.net.URLClassLoader$1.run(URLClassLoader.java:369)
at java.net.URLClassLoader$1.run(URLClassLoader.java:363)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:362)
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
com.imatsolutions.database.ApacheDerbyTest.testDirectlyToDerby(ApacheDerbyTest.java:78)
java.lang.UnsupportedClassVersionError:
*org/apache/derby/shared/common/util/ArrayUtil* has been compiled by
a more recent version of the Java Runtime (class file version 53.0),
this version of the Java Runtime only recognizes class file versions
up to 52.0
...
java.lang.UnsupportedClassVersionError:
*org/apache/derby/jdbc/BasicEmbeddedDataSource40* has been compiled
by a more recent version of the Java Runtime (class file version
53.0), this version of the Java Runtime only recognizes class file
versions up to 52.0
...
Just in case there is an older version of Derby in there somewhere,
command-line Maven reports:
[echoproperties]
maven.dependency.org.apache.derby.derby.jar.path=/home/russ/.m2/repository/org/apache/derby/derby/10.15.2.0/derby-10.15.2.0.jar
[echoproperties]
maven.dependency.org.apache.derby.derbyshared.jar.path=/home/russ/.m2/repository/org/apache/derby/derbyshared/10.15.2.0/derbyshared-10.15.2.0.jar
[echoproperties]
maven.dependency.org.apache.derby.derbytools.jar.path=/home/russ/.m2/repository/org/apache/derby/derbytools/10.15.2.0/derbytools-10.15.2.0.jar
.
.
.
[echoproperties]
org.apache.derby\:derby\:jar=/home/russ/.m2/repository/org/apache/derby/derby/10.15.2.0/derby-10.15.2.0.jar
[echoproperties]
org.apache.derby\:derbyshared\:jar=/home/russ/.m2/repository/org/apache/derby/derbyshared/10.15.2.0/derbyshared-10.15.2.0.jar
[echoproperties]
org.apache.derby\:derbytools\:jar=/home/russ/.m2/repository/org/apache/derby/derbytools/10.15.2.0/derbytools-10.15.2.0.jar
All of this works in IntelliJ IDEA, which itself reports this and
doesn't get UnsupportedClassVersionErrorwhen I run this unit test:
- External Libraries
> Maven: org.apache.derby:derby:10.15.2.0
> Maven: org.apache.derby:derbyshared:10.15.2.0
> Maven: org.apache.derby:derbytools:10.15.2.0
Again, thanks for looking at this.
On 6/26/20 6:46 AM, Rick Hillegas wrote:
> 1) Do you have a stack trace showing what class can't be resolved?
>
> 2) What happens if you do a Class.forName() on the following classes,
> which live, respectively, in derby.jar, derbyshared.jar, and
> derbytools.jar:
>
> org.apache.derby.impl.jdbc.EmbedConnection
> org.apache.derby.shared.common.util.ArrayUtil
> org.apache.derby.jdbc.BasicEmbeddedDataSource40
>
> Thanks,
> -Rick
>
> On 6/25/20 4:20 PM, Russell Bateman wrote:
>> Oops. I spoke too soon. I still had my JUnit tests @Ignore'd. It
>> doesn't work yet. I still get "no suitable driver." I added
>> derbytools too, but that made no difference. Further thoughts?
>>
>>
>> On 6/25/20 5:01 PM, Russell Bateman wrote:
>>> Thank you; that's very kind. It now works. (I'm not using
>>> DataSources for now.) I greatly appreciate your help.
>>>
>>> Best regards,
>>> Russ
>>>
>>> On 6/25/20 4:48 PM, Rick Hillegas wrote:
>>>> The 10.15 family of releases introduced a JPMS modularization of
>>>> Derby. That re-factored the code a bit. You will need to add
>>>> derbyshared.jar to the classpath and build dependencies. If you are
>>>> using DataSources, then you will also need to add derbytools.jar.
>>>> Please see the detailed release note for DERBY-6945 on the
>>>> 10.15.1.3 download page:
>>>> http://db.apache.org/derby/releases/release-10.15.1.3.html
>>>>
>>>> Hope this helps,
>>>> -Rick
>>>>
>>>> On 6/25/20 1:28 PM, Russell Bateman wrote:
>>>>> I have very recent code that works in a JUnit test case.
>>>>>
>>>>> @Test
>>>>> public void test()
>>>>> {
>>>>> final String DATABASE =
>>>>> "jdbc:derby:memory:sampledb;create=true";
>>>>> final String USERNAME = "sa";
>>>>> final String PASSWORD = "sa";
>>>>>
>>>>> final String CREATE_TABLE = "CREATE TABLE names ( oid INT
>>>>> GENERATED ALWAYS AS IDENTITY, name VARCHAR( 20 ) )";
>>>>> final String INSERT_NAME1 = "INSERT INTO names ( name )
>>>>> VALUES (
>>>>> 'Jack' )";
>>>>> final String QUERY = "SELECT oid, name FROM names";
>>>>>
>>>>> Connection connection = null;
>>>>>
>>>>> try
>>>>> {
>>>>> connection = DriverManager.getConnection( DATABASE, USERNAME,
>>>>> PASSWORD );
>>>>>
>>>>> Statement statement = connection.createStatement();
>>>>> ...
>>>>>
>>>>> In /pom.xml/, I have the following:
>>>>>
>>>>> <dependency>
>>>>> <groupId>org.apache.derby</groupId>
>>>>> <artifactId>*derby*</artifactId>
>>>>> <version>10.15.2.0</version>
>>>>> <scope>test</scope>
>>>>> </dependency>
>>>>>
>>>>> I only want to use Derby _in-memory_ backing some unit test cases
>>>>> that need a database (not requiring a running server or dæmon,
>>>>> etc.). It all works perfectly inside IntelliJ IDEA.
>>>>>
>>>>> However, when I build from the command line (mvn clean package), I
>>>>> see this and can find no solution:
>>>>>
>>>>> java.sql.SQLException: No suitable driver found for
>>>>> jdbc:derby:memory:sampledb;create=true
>>>>> at
>>>>> java.sql.DriverManager.getConnection(DriverManager.java:689)
>>>>> at
>>>>> java.sql.DriverManager.getConnection(DriverManager.java:247)
>>>>> at
>>>>> com.imatsolutions.database.ApacheDerbyTest.testDirectlyToDerby(ApacheDerbyTest.java:78)
>>>>>
>>>>>
>>>>> In /pom.xml/, I have tried adding the following, and I have tried
>>>>> many other solutions, some of which are supposed to be obsolete (
>>>>> Class.for(...), DriverManager.registerDriver( ... ), etc. ), but
>>>>> cannot find a happy solution.
>>>>>
>>>>> <dependency>
>>>>> <groupId>org.apache.derby</groupId>
>>>>> <artifactId>*derbyclient*</artifactId>
>>>>> <version>10.15.2.0</version>
>>>>> <scope>test</scope>
>>>>> </dependency>
>>>>>
>>>>> Any comment would be welcome.
>>>>>
>>>>> Thanks.
>>>>>
>>>>>
>>>>
>>>
>>
>>
>
Re: java.sql.SQLException: No suitable driver found for
jdbc:derby:memory:sampledb;create=true
Posted by Rick Hillegas <ri...@gmail.com>.
1) Do you have a stack trace showing what class can't be resolved?
2) What happens if you do a Class.forName() on the following classes,
which live, respectively, in derby.jar, derbyshared.jar, and derbytools.jar:
org.apache.derby.impl.jdbc.EmbedConnection
org.apache.derby.shared.common.util.ArrayUtil
org.apache.derby.jdbc.BasicEmbeddedDataSource40
Thanks,
-Rick
On 6/25/20 4:20 PM, Russell Bateman wrote:
> Oops. I spoke too soon. I still had my JUnit tests @Ignore'd. It
> doesn't work yet. I still get "no suitable driver." I added derbytools
> too, but that made no difference. Further thoughts?
>
>
> On 6/25/20 5:01 PM, Russell Bateman wrote:
>> Thank you; that's very kind. It now works. (I'm not using DataSources
>> for now.) I greatly appreciate your help.
>>
>> Best regards,
>> Russ
>>
>> On 6/25/20 4:48 PM, Rick Hillegas wrote:
>>> The 10.15 family of releases introduced a JPMS modularization of
>>> Derby. That re-factored the code a bit. You will need to add
>>> derbyshared.jar to the classpath and build dependencies. If you are
>>> using DataSources, then you will also need to add derbytools.jar.
>>> Please see the detailed release note for DERBY-6945 on the 10.15.1.3
>>> download page:
>>> http://db.apache.org/derby/releases/release-10.15.1.3.html
>>>
>>> Hope this helps,
>>> -Rick
>>>
>>> On 6/25/20 1:28 PM, Russell Bateman wrote:
>>>> I have very recent code that works in a JUnit test case.
>>>>
>>>> @Test
>>>> public void test()
>>>> {
>>>> final String DATABASE =
>>>> "jdbc:derby:memory:sampledb;create=true";
>>>> final String USERNAME = "sa";
>>>> final String PASSWORD = "sa";
>>>>
>>>> final String CREATE_TABLE = "CREATE TABLE names ( oid INT
>>>> GENERATED ALWAYS AS IDENTITY, name VARCHAR( 20 ) )";
>>>> final String INSERT_NAME1 = "INSERT INTO names ( name ) VALUES (
>>>> 'Jack' )";
>>>> final String QUERY = "SELECT oid, name FROM names";
>>>>
>>>> Connection connection = null;
>>>>
>>>> try
>>>> {
>>>> connection = DriverManager.getConnection( DATABASE, USERNAME,
>>>> PASSWORD );
>>>>
>>>> Statement statement = connection.createStatement();
>>>> ...
>>>>
>>>> In /pom.xml/, I have the following:
>>>>
>>>> <dependency>
>>>> <groupId>org.apache.derby</groupId>
>>>> <artifactId>*derby*</artifactId>
>>>> <version>10.15.2.0</version>
>>>> <scope>test</scope>
>>>> </dependency>
>>>>
>>>> I only want to use Derby _in-memory_ backing some unit test cases
>>>> that need a database (not requiring a running server or dæmon,
>>>> etc.). It all works perfectly inside IntelliJ IDEA.
>>>>
>>>> However, when I build from the command line (mvn clean package), I
>>>> see this and can find no solution:
>>>>
>>>> java.sql.SQLException: No suitable driver found for
>>>> jdbc:derby:memory:sampledb;create=true
>>>> at
>>>> java.sql.DriverManager.getConnection(DriverManager.java:689)
>>>> at
>>>> java.sql.DriverManager.getConnection(DriverManager.java:247)
>>>> at
>>>> com.imatsolutions.database.ApacheDerbyTest.testDirectlyToDerby(ApacheDerbyTest.java:78)
>>>>
>>>>
>>>> In /pom.xml/, I have tried adding the following, and I have tried
>>>> many other solutions, some of which are supposed to be obsolete (
>>>> Class.for(...), DriverManager.registerDriver( ... ), etc. ), but
>>>> cannot find a happy solution.
>>>>
>>>> <dependency>
>>>> <groupId>org.apache.derby</groupId>
>>>> <artifactId>*derbyclient*</artifactId>
>>>> <version>10.15.2.0</version>
>>>> <scope>test</scope>
>>>> </dependency>
>>>>
>>>> Any comment would be welcome.
>>>>
>>>> Thanks.
>>>>
>>>>
>>>
>>
>
>
Re: java.sql.SQLException: No suitable driver found for
jdbc:derby:memory:sampledb;create=true
Posted by Russell Bateman <ru...@windofkeltia.com>.
Oops. I spoke too soon. I still had my JUnit tests @Ignore'd. It doesn't
work yet. I still get "no suitable driver." I added derbytools too, but
that made no difference. Further thoughts?
On 6/25/20 5:01 PM, Russell Bateman wrote:
> Thank you; that's very kind. It now works. (I'm not using DataSources
> for now.) I greatly appreciate your help.
>
> Best regards,
> Russ
>
> On 6/25/20 4:48 PM, Rick Hillegas wrote:
>> The 10.15 family of releases introduced a JPMS modularization of
>> Derby. That re-factored the code a bit. You will need to add
>> derbyshared.jar to the classpath and build dependencies. If you are
>> using DataSources, then you will also need to add derbytools.jar.
>> Please see the detailed release note for DERBY-6945 on the 10.15.1.3
>> download page:
>> http://db.apache.org/derby/releases/release-10.15.1.3.html
>>
>> Hope this helps,
>> -Rick
>>
>> On 6/25/20 1:28 PM, Russell Bateman wrote:
>>> I have very recent code that works in a JUnit test case.
>>>
>>> @Test
>>> public void test()
>>> {
>>> final String DATABASE = "jdbc:derby:memory:sampledb;create=true";
>>> final String USERNAME = "sa";
>>> final String PASSWORD = "sa";
>>>
>>> final String CREATE_TABLE = "CREATE TABLE names ( oid INT
>>> GENERATED ALWAYS AS IDENTITY, name VARCHAR( 20 ) )";
>>> final String INSERT_NAME1 = "INSERT INTO names ( name ) VALUES (
>>> 'Jack' )";
>>> final String QUERY = "SELECT oid, name FROM names";
>>>
>>> Connection connection = null;
>>>
>>> try
>>> {
>>> connection = DriverManager.getConnection( DATABASE, USERNAME,
>>> PASSWORD );
>>>
>>> Statement statement = connection.createStatement();
>>> ...
>>>
>>> In /pom.xml/, I have the following:
>>>
>>> <dependency>
>>> <groupId>org.apache.derby</groupId>
>>> <artifactId>*derby*</artifactId>
>>> <version>10.15.2.0</version>
>>> <scope>test</scope>
>>> </dependency>
>>>
>>> I only want to use Derby _in-memory_ backing some unit test cases
>>> that need a database (not requiring a running server or dæmon,
>>> etc.). It all works perfectly inside IntelliJ IDEA.
>>>
>>> However, when I build from the command line (mvn clean package), I
>>> see this and can find no solution:
>>>
>>> java.sql.SQLException: No suitable driver found for
>>> jdbc:derby:memory:sampledb;create=true
>>> at java.sql.DriverManager.getConnection(DriverManager.java:689)
>>> at java.sql.DriverManager.getConnection(DriverManager.java:247)
>>> at
>>> com.imatsolutions.database.ApacheDerbyTest.testDirectlyToDerby(ApacheDerbyTest.java:78)
>>>
>>>
>>> In /pom.xml/, I have tried adding the following, and I have tried
>>> many other solutions, some of which are supposed to be obsolete (
>>> Class.for(...), DriverManager.registerDriver( ... ), etc. ), but
>>> cannot find a happy solution.
>>>
>>> <dependency>
>>> <groupId>org.apache.derby</groupId>
>>> <artifactId>*derbyclient*</artifactId>
>>> <version>10.15.2.0</version>
>>> <scope>test</scope>
>>> </dependency>
>>>
>>> Any comment would be welcome.
>>>
>>> Thanks.
>>>
>>>
>>
>
Re: java.sql.SQLException: No suitable driver found for
jdbc:derby:memory:sampledb;create=true
Posted by Russell Bateman <ru...@windofkeltia.com>.
Thank you; that's very kind. It now works. (I'm not using DataSources
for now.) I greatly appreciate your help.
Best regards,
Russ
On 6/25/20 4:48 PM, Rick Hillegas wrote:
> The 10.15 family of releases introduced a JPMS modularization of
> Derby. That re-factored the code a bit. You will need to add
> derbyshared.jar to the classpath and build dependencies. If you are
> using DataSources, then you will also need to add derbytools.jar.
> Please see the detailed release note for DERBY-6945 on the 10.15.1.3
> download page: http://db.apache.org/derby/releases/release-10.15.1.3.html
>
> Hope this helps,
> -Rick
>
> On 6/25/20 1:28 PM, Russell Bateman wrote:
>> I have very recent code that works in a JUnit test case.
>>
>> @Test
>> public void test()
>> {
>> final String DATABASE = "jdbc:derby:memory:sampledb;create=true";
>> final String USERNAME = "sa";
>> final String PASSWORD = "sa";
>>
>> final String CREATE_TABLE = "CREATE TABLE names ( oid INT
>> GENERATED ALWAYS AS IDENTITY, name VARCHAR( 20 ) )";
>> final String INSERT_NAME1 = "INSERT INTO names ( name ) VALUES (
>> 'Jack' )";
>> final String QUERY = "SELECT oid, name FROM names";
>>
>> Connection connection = null;
>>
>> try
>> {
>> connection = DriverManager.getConnection( DATABASE, USERNAME,
>> PASSWORD );
>>
>> Statement statement = connection.createStatement();
>> ...
>>
>> In /pom.xml/, I have the following:
>>
>> <dependency>
>> <groupId>org.apache.derby</groupId>
>> <artifactId>*derby*</artifactId>
>> <version>10.15.2.0</version>
>> <scope>test</scope>
>> </dependency>
>>
>> I only want to use Derby _in-memory_ backing some unit test cases
>> that need a database (not requiring a running server or dæmon, etc.).
>> It all works perfectly inside IntelliJ IDEA.
>>
>> However, when I build from the command line (mvn clean package), I
>> see this and can find no solution:
>>
>> java.sql.SQLException: No suitable driver found for
>> jdbc:derby:memory:sampledb;create=true
>> at java.sql.DriverManager.getConnection(DriverManager.java:689)
>> at java.sql.DriverManager.getConnection(DriverManager.java:247)
>> at
>> com.imatsolutions.database.ApacheDerbyTest.testDirectlyToDerby(ApacheDerbyTest.java:78)
>>
>>
>> In /pom.xml/, I have tried adding the following, and I have tried
>> many other solutions, some of which are supposed to be obsolete (
>> Class.for(...), DriverManager.registerDriver( ... ), etc. ), but
>> cannot find a happy solution.
>>
>> <dependency>
>> <groupId>org.apache.derby</groupId>
>> <artifactId>*derbyclient*</artifactId>
>> <version>10.15.2.0</version>
>> <scope>test</scope>
>> </dependency>
>>
>> Any comment would be welcome.
>>
>> Thanks.
>>
>>
>
Re: java.sql.SQLException: No suitable driver found for
jdbc:derby:memory:sampledb;create=true
Posted by Rick Hillegas <ri...@gmail.com>.
The 10.15 family of releases introduced a JPMS modularization of Derby.
That re-factored the code a bit. You will need to add derbyshared.jar to
the classpath and build dependencies. If you are using DataSources, then
you will also need to add derbytools.jar. Please see the detailed
release note for DERBY-6945 on the 10.15.1.3 download page:
http://db.apache.org/derby/releases/release-10.15.1.3.html
Hope this helps,
-Rick
On 6/25/20 1:28 PM, Russell Bateman wrote:
> I have very recent code that works in a JUnit test case.
>
> @Test
> public void test()
> {
> final String DATABASE = "jdbc:derby:memory:sampledb;create=true";
> final String USERNAME = "sa";
> final String PASSWORD = "sa";
>
> final String CREATE_TABLE = "CREATE TABLE names ( oid INT
> GENERATED ALWAYS AS IDENTITY, name VARCHAR( 20 ) )";
> final String INSERT_NAME1 = "INSERT INTO names ( name ) VALUES (
> 'Jack' )";
> final String QUERY = "SELECT oid, name FROM names";
>
> Connection connection = null;
>
> try
> {
> connection = DriverManager.getConnection( DATABASE, USERNAME,
> PASSWORD );
>
> Statement statement = connection.createStatement();
> ...
>
> In /pom.xml/, I have the following:
>
> <dependency>
> <groupId>org.apache.derby</groupId>
> <artifactId>*derby*</artifactId>
> <version>10.15.2.0</version>
> <scope>test</scope>
> </dependency>
>
> I only want to use Derby _in-memory_ backing some unit test cases that
> need a database (not requiring a running server or dæmon, etc.). It
> all works perfectly inside IntelliJ IDEA.
>
> However, when I build from the command line (mvn clean package), I see
> this and can find no solution:
>
> java.sql.SQLException: No suitable driver found for
> jdbc:derby:memory:sampledb;create=true
> at java.sql.DriverManager.getConnection(DriverManager.java:689)
> at java.sql.DriverManager.getConnection(DriverManager.java:247)
> at
> com.imatsolutions.database.ApacheDerbyTest.testDirectlyToDerby(ApacheDerbyTest.java:78)
>
> In /pom.xml/, I have tried adding the following, and I have tried many
> other solutions, some of which are supposed to be obsolete (
> Class.for(...), DriverManager.registerDriver( ... ), etc. ), but
> cannot find a happy solution.
>
> <dependency>
> <groupId>org.apache.derby</groupId>
> <artifactId>*derbyclient*</artifactId>
> <version>10.15.2.0</version>
> <scope>test</scope>
> </dependency>
>
> Any comment would be welcome.
>
> Thanks.
>
>