Armed with more information on Drizzle JDBC being a JDBC 4.0 implementation (helps to explain my issues in Getting started with Drizzle JDBC) I took the time to read about some other new JDBC 4.0 features.
There was reference to handling chained exceptions, however when trying to get this working for SQLException was more complex on Ubuntu 9.04 then I anticipated.
My first problem was an apparent source level problem.
$ javac ExampleDrizzle.java ---------- 1. ERROR in ExampleDrizzle.java (at line 14) for(Throwable e : sx ) { ^^^^^^^^^^^^^^^^ Syntax error, 'for each' statements are only available if source level is 1.5
That’s weird, what java version was I running now I’d changed with update-alternatives –config java yesterday.
$ java -version java version "1.6.0_16" Java(TM) SE Runtime Environment (build 1.6.0_16-b01) Java HotSpot(TM) 64-Bit Server VM (build 14.2-b01, mixed mode)
No issues here, a quick man reference gives me:
-1.5 set compliance level to 1.5
I try that, and well that fixes one problem, but creates another.
$ javac -1.5 ExampleDrizzle.java ---------- 1. ERROR in ExampleDrizzle.java (at line 14) for(Throwable e : sx ) { ^^ Can only iterate over an array or an instance of java.lang.Iterable
Now Class SQLException 1.6 javadocs shows SQLException as implementing the generics Iterable<Throwable>, while 1.5 javadoc does not. I guess I need to use 1.6 then.
$ javac -1.6 ExampleDrizzle.java Annotation processing got disabled, since it requires a 1.6 compliant JVM ---------- 1. ERROR in ExampleDrizzle.java (at line 14) for(Throwable e : sx ) { ^^ Can only iterate over an array or an instance of java.lang.Iterable
Wait a minute, I’m using a 1.6 compliant JVM. Double checking
$ ls -al /etc/alternatives/java* lrwxrwxrwx 1 root root 36 2009-09-17 18:53 /etc/alternatives/java -> /usr/lib/jvm/java-6-sun/jre/bin/java lrwxrwxrwx 1 root root 46 2009-09-17 18:53 /etc/alternatives/java.1.gz -> /usr/lib/jvm/java-6-sun/jre/man/man1/java.1.gz lrwxrwxrwx 1 root root 31 2009-09-17 17:50 /etc/alternatives/javac -> /usr/lib/jvm/java-gcj/bin/javac lrwxrwxrwx 1 root root 41 2009-09-17 17:50 /etc/alternatives/javac.1.gz -> /usr/lib/jvm/java-gcj/man/man1/javac.1.gz lrwxrwxrwx 1 root root 33 2009-09-17 17:50 /etc/alternatives/javadoc -> /usr/lib/jvm/java-gcj/bin/javadoc lrwxrwxrwx 1 root root 43 2009-09-17 17:50 /etc/alternatives/javadoc.1.gz -> /usr/lib/jvm/java-gcj/man/man1/javadoc.1.gz lrwxrwxrwx 1 root root 31 2009-09-17 17:50 /etc/alternatives/javah -> /usr/lib/jvm/java-gcj/bin/javah lrwxrwxrwx 1 root root 41 2009-09-17 17:50 /etc/alternatives/javah.1.gz -> /usr/lib/jvm/java-gcj/man/man1/javah.1.gz lrwxrwxrwx 1 root root 33 2009-09-11 10:06 /etc/alternatives/javap -> /usr/lib/jvm/java-6-sun/bin/javap lrwxrwxrwx 1 root root 43 2009-09-11 10:06 /etc/alternatives/javap.1.gz -> /usr/lib/jvm/java-6-sun/man/man1/javap.1.gz lrwxrwxrwx 1 root root 39 2009-09-11 10:06 /etc/alternatives/java_vm -> /usr/lib/jvm/java-6-sun/jre/bin/java_vm lrwxrwxrwx 1 root root 38 2009-09-11 10:06 /etc/alternatives/javaws -> /usr/lib/jvm/java-6-sun/jre/bin/javaws lrwxrwxrwx 1 root root 48 2009-09-11 10:06 /etc/alternatives/javaws.1.gz -> /usr/lib/jvm/java-6-sun/jre/man/man1/javaws.1.gz
javac is not using Sun Java 6. I have no idea how that happened, but it explains now the problem, should be checking javac version, not java version.
$ javac -version Eclipse Java Compiler 0.894_R34x, 3.4.2 release, Copyright IBM Corp 2000, 2008. All rights reserved.
What the? I was writing Java code on this server by hand, but decided last night to install eclipse after the fact. Did this affect this. I’m not certain whether I installed eclipse before or after my work last night.
I try to change the alternatives again.
$ sudo update-alternatives --config java There are 4 alternatives which provide `java'. Selection Alternative ----------------------------------------------- * 1 /usr/lib/jvm/java-6-sun/jre/bin/java 2 /usr/bin/gij-4.3 3 /usr/bin/gij-4.2 + 4 /usr/lib/jvm/java-gcj/jre/bin/java Press enter to keep the default[*], or type selection number: 1 Using '/usr/lib/jvm/java-6-sun/jre/bin/java' to provide 'java'. $ javac -version Eclipse Java Compiler 0.894_R34x, 3.4.2 release, Copyright IBM Corp 2000, 2008. All rights reserved.
That doesn’t work. One needs to know that java and javac operate independently.
$ sudo update-alternatives --config javac There are 4 alternatives which provide `javac'. Selection Alternative ----------------------------------------------- 1 /usr/lib/jvm/java-6-sun/bin/javac 2 /usr/bin/ecj 3 /usr/bin/gcj-wrapper-4.3 *+ 4 /usr/lib/jvm/java-gcj/bin/javac Press enter to keep the default[*], or type selection number: 1 Using '/usr/lib/jvm/java-6-sun/bin/javac' to provide 'javac'. $ javac -version javac 1.6.0_16 $ javac ExampleDrizzle.java
Buyer beware with Ubuntu and it’s rather messed up implementation approach toward alternative java JVM’s.