Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / Databases / May 2008

Tip: Looking for answers? Try searching our database.

gcj 4.2.1 entails "Unexpected exception encountered during query"     with mysql-connector-java-5.1.6-bin.jar

Thread view: 
Christian - 14 May 2008 20:12 GMT
Hi!

I wrote a java-application that uses mysql-connector-java-5.1.6-
bin.jar and does well as long as Java(TM) 2 Runtime Environment,
Standard Edition (build 1.5.0_15-b04) executes the bytecode. I tried
to gain some extra-speed by compiling native.

The compiling works well again but starting the native code leads into
an error: “Unexpected exception encountered during query”. I searched
the web for a while but did not find a useful hint so I’d really
appreciate your advise where to search.

Is the connector not designed to be used for compiling native code? Or
is there a way to modify my Java-Code?

Thanks in advance

Christian

Java-Source
===========

System.out.print("Loading driver " + DATABASE_DRIVER + " ... ");

try {
    Class.forName(DATABASE_DRIVER);
}
catch (ClassNotFoundException classNotFoundException) {
    throw new
InstantiationError(classNotFoundException.getMessage());
}

System.out.println("loaded");
System.out.print("Connecting to " + server + " ... ");

try {
    String url = "jdbc:mysql://" + server + ':' + port + "/?user=" +
userName;
    if ((passWord != null) && (passWord.trim().length() > 0))
         url = url + "&password=" + passWord.trim();
    System.out.print("via " + url + " ");
    connection = DriverManager.getConnection(url);
}
catch (SQLException sqlException) {
    throw new InstantiationError(sqlException.getMessage());
}

System.out.println("connected");

Java-VM coping with the code
============================
java version "1.5.0_15"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0_15-b04)
Java HotSpot(TM) Client VM (build 1.5.0_15-b04, mixed mode)

CLASSPATH
=========
.:/home/kruggel/public_html/freedb2mysql/mysql-connector-java-5.1.6-
bin.jar

Application works fine with VM
==============================
> java freedb2mysql.Starter -dbHost 10.0.0.11 -queryServerForArtist AC%DC -dbUser freedb -dbName freedbsmall
Loading driver com.mysql.jdbc.Driver ... loaded
Connecting to 10.0.0.11 ... via jdbc:mysql://10.0.0.11:3306/?
user=freedb connected
Querying freedbsmall (2084153 entries) for disks by artists named AC
%DC

GCJ that compiles fine as well
==============================
gcj (GCC) 4.2.1 (SUSE Linux)
Copyright (C) 2007 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is
NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE.

gcj -v -B /home/kruggel/src/freedb freedb2mysql/*.java freedb2mysql/
data/*.java freedb2mysql/extraction/*.java freedb2mysql/retrieval/
*.java freedb2mysql/spooling/*.java freedb2mysql/textanalysis/*.java
freedb2mysql/util/*.java freedb2mysql/validation/*.java -o
FreeDB2MySQL --main=freedb2mysql.Starter

Native application crashes
==========================
> ./FreeDB2MySQL -dbHost 10.0.0.11 -queryServerForArtist AC%DC -dbUser freedb -dbName freedbsmall
Loading driver com.mysql.jdbc.Driver ... loaded
Connecting to 10.0.0.11 ... via jdbc:mysql://10.0.0.11:3306/?
user=freedb
Failed to create MySQLConnector
Unexpected exception encountered during query.

BOOOOSH!
Arne Vajhøj - 15 May 2008 00:42 GMT
> I wrote a java-application that uses mysql-connector-java-5.1.6-
> bin.jar and does well as long as Java(TM) 2 Runtime Environment,
> Standard Edition (build 1.5.0_15-b04) executes the bytecode. I tried
> to gain some extra-speed by compiling native.

You mean you want to loose some speed by using gcj ?

> The compiling works well again but starting the native code leads into
> an error: “Unexpected exception encountered during query”. I searched
> the web for a while but did not find a useful hint so I’d really
> appreciate your advise where to search.

> Unexpected exception encountered during query.
>
> BOOOOSH!

GCJ only supports some of Java 1.4.2 (not 1.5) and have lots of bugs.

So you get:
- less features
- more bugs
- worse performance
by using it.

Easy choice !

Arne
Lew - 15 May 2008 04:38 GMT
Christian wrote:
>> I wrote a java-application that uses mysql-connector-java-5.1.6-
>> bin.jar and does well as long as Java(TM) 2 Runtime Environment,
>> Standard Edition (build 1.5.0_15-b04) executes the bytecode. I tried
>> to gain some extra-speed by compiling native.

Given that Java Hotspot runs at approximately the same speed as natively
compiled code for the most part already, how much more speed could you
conceive of getting?

> You mean you want to lose some speed by using gcj ?

Oh, of course.

> GCJ only supports some of Java 1.4.2 (not 1.5) and have lots of bugs.

Their own website only claims that it
> ... supports most of the 1.4 libraries plus some 1.5 additions.

It supports "most" of the libraries and only "some" of the 1.5 "additions"
(whatever they mean by that).  Apparently your JDBC driver library isn't among
"most" of the ones supported.

> So you get:
> - less features
[quoted text clipped - 3 lines]
>
> Easy choice !

It's funny how GCJ has not improved at all since I first heard of it some
seven or eight years back, it seems.

Signature

Lew

Silvio Bierman - 15 May 2008 09:38 GMT
> It's funny how GCJ has not improved at all since I first heard of it
> some seven or eight years back, it seems.

What is even more astonishing is that Linux distros ship it as the
default "Java" system.
Arne Vajhøj - 15 May 2008 22:51 GMT
>> It's funny how GCJ has not improved at all since I first heard of it
>> some seven or eight years back, it seems.
>
> What is even more astonishing is that Linux distros ship it as the
> default "Java" system.

That is historic determined. The original license for SUN Java did
not fit well with the Linux distros.

After SUN has has open source their Java, then I would expect
that to become increasingly used as default Java by Linux
distros.

Arne
Arne Vajhøj - 15 May 2008 22:53 GMT
>> You mean you want to lose some speed by using gcj ?
>> So you get:
[quoted text clipped - 7 lines]
> It's funny how GCJ has not improved at all since I first heard of it
> some seven or eight years back, it seems.

The compiler is easy, the JVM is doable but keeping up with the library
is very difficult. It is huge.

If you look at Mono then they have more or less the equivalent problem
with the same status.

Arne


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.