Mac OS X Connector/J classpath problem
Posted by: Timothy DiLauro
Date: December 29, 2004 01:59PM

I'm running Mac OS X 10.3 with all the latest updates, including the latest Java updates. Others have mentioned in this forum that they have solved the problem I am about describe by applying the latest Java updates. This seems not to be the case for me.

I'm having a problem connecting to a MySQL 4.1.8 server using Connector/J. The doesn't really have anything to do with which version of the MySQL JDBC driver, but appears to occur because of classpath problems.

I wrote a small test program that uses the connector to return usernames in the form "<user>@<host>" from the "mysql" database.

I have *no* problem connecting to the database using the "mysql" command with the "-h" argument. Furthermore, I have no problem if I add ...




to the java command (see below -- after the failure -- for two examples of success. If, however, I put the connector jar file in the classpath, I get failure.

Does anyone know how I would resolve this under Mac OS X? I don't see any older versions of the connector jar file anywhere under the /System/Library/Frameworks/JavaVM.framework hierarchy.

When I run java with "-verbose" it shows some com.mysql.jdbc classes being loaded, but does not indicate where they were loaded from (they do

$ java -verbose -cp . test 2>&1 | less

[Opened /System/Library/Frameworks/JavaVM.framework/Versions/1.4.2/Classes/classes.jar]
[Opened /System/Library/Frameworks/JavaVM.framework/Versions/1.4.2/Classes/ui.jar]
[Opened /System/Library/Frameworks/JavaVM.framework/Versions/1.4.2/Classes/laf.jar]
[Opened /System/Library/Frameworks/JavaVM.framework/Versions/1.4.2/Classes/sunrsasign.jar]
[Opened /System/Library/Frameworks/JavaVM.framework/Versions/1.4.2/Classes/jsse.jar]
[Opened /System/Library/Frameworks/JavaVM.framework/Versions/1.4.2/Classes/jce.jar]
[Opened /System/Library/Frameworks/JavaVM.framework/Versions/1.4.2/Classes/charsets.jar]
<snip />
[Loaded java.sql.Driver from /System/Library/Frameworks/JavaVM.framework/Versions/1.4.2/Classes/classes.jar]
[Loaded com.mysql.jdbc.Driver]
[Loaded java.sql.DriverManager from /System/Library/Frameworks/JavaVM.framework/Versions/1.4.2/Classes/classes.jar]
[Loaded java.sql.SQLPermission from /System/Library/Frameworks/JavaVM.framework/Versions/1.4.2/Classes/classes.jar]
[Loaded java.sql.DriverInfo from /System/Library/Frameworks/JavaVM.framework/Versions/1.4.2/Classes/classes.jar]
[Loaded com.mysql.jdbc.Connection]
<snip />
[Loaded java.sql.ResultSet from /System/Library/Frameworks/JavaVM.framework/Vers
[Loaded com.mysql.jdbc.ResultSet]
[Loaded java.lang.InterruptedException from shared objects file]
[Loaded com.mysql.jdbc.NotImplemented]
[Loaded java.sql.DatabaseMetaData from /System/Library/Frameworks/JavaVM.framework/Versions/1.4.2/Classes/classes.jar]
[Loaded java.sql.Statement from /System/Library/Frameworks/JavaVM.framework/Versions/1.4.2/Classes/classes.jar]
[Loaded java.sql.PreparedStatement from /System/Library/Frameworks/JavaVM.framework/Versions/1.4.2/Classes/classes.jar]
[Loaded java.sql.CallableStatement from /System/Library/Frameworks/JavaVM.framework/Versions/1.4.2/Classes/classes.jar]
[Loaded com.mysql.jdbc.SocketFactory]
[Loaded com.mysql.jdbc.StandardSocketFactory]
[Loaded java.lang.NoSuchMethodException from /System/Library/Frameworks/JavaVM.framework/Versions/1.4.2/Classes/classes.jar]
[Loaded from shared objects file]
[Loaded com.mysql.jdbc.CharsetMapping]
<snip />
[Loaded com.mysql.jdbc.MysqlIO]
<snip />
[Loaded com.mysql.jdbc.PacketTooBigException]
[Loaded com.mysql.jdbc.UpdatableResultSet]
[Loaded com.mysql.jdbc.RowData]
[Loaded com.mysql.jdbc.RowDataStatic]
[Loaded com.mysql.jdbc.RowDataDynamic]
[Loaded com.mysql.jdbc.Buffer]
<snip />
[Loaded com.mysql.jdbc.SQLError]
[Loaded com.mysql.jdbc.Util]
<snip />

This command line goes on to fail in the same way as the command below.

Does anyone have suggestions about how to track this down and resolve it under Mac OS X 10.3?



# This command fails
$ java -cp /usr/local/src/java/lib/mysql-connector-java-3.0.16-ga-bin.jar:. test
==> SQLException:
Message: Communication link failure:, underlying cause: Unexpected end of input stream

MESSAGE: Unexpected end of input stream

STACKTRACE: Unexpected end of input stream
at com.mysql.jdbc.MysqlIO.readPacket(
at com.mysql.jdbc.MysqlIO.doHandshake(
at com.mysql.jdbc.Connection.createNewIO(
at com.mysql.jdbc.Connection.<init>(
at com.mysql.jdbc.Driver.connect(
at java.sql.DriverManager.getConnection(
at java.sql.DriverManager.getConnection(
at test.main(


SQLState: 08S01
ErrorCode: 0

# This command ran successfully
$ java -Xbootclasspath/a:/usr/local/src/java/lib/mysql-connector-java-3.0.16-ga-bin.jar test
Username = user@%
Username = user@localhost

# This command ran successfully
$ java -Xbootclasspath/p:/usr/local/src/java/lib/mysql-connector-java-3.0.16-ga-bin.jar test
Username = user@%
Username = user@localhost

Keywords: mysql 4.1.8 Mac OS X MacOSX osx

Options: ReplyQuote

Written By
Mac OS X Connector/J classpath problem
December 29, 2004 01:59PM

Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.