Bug #13430 Socket Exception when connection to local database on Mac
Submitted: 23 Sep 2005 15:20 Modified: 27 Sep 2005 9:08
Reporter: Russ Fennell Email Updates:
Status: Not a Bug Impact on me:
None 
Category:Connector / J Severity:S3 (Non-critical)
Version:4.1.13 OS:MacOS (Mac OS X 10.4.2)
Assigned to: CPU Architecture:Any

[23 Sep 2005 15:20] Russ Fennell
Description:
I have a locally installed database and a simple piece of Java to select data from a table. I get the following when the DriverManager is connecting:

Error: Communications link failure due to underlying exception: 

** BEGIN NESTED EXCEPTION ** 

java.net.SocketException
MESSAGE: java.net.SocketException: Reply from SOCKS server has bad version

STACKTRACE:

java.net.SocketException: java.net.SocketException: Reply from SOCKS server has bad version
	at com.mysql.jdbc.StandardSocketFactory.connect(StandardSocketFactory.java:156)
	at com.mysql.jdbc.MysqlIO.<init>(MysqlIO.java:283)
	at com.mysql.jdbc.Connection.createNewIO(Connection.java:2541)
	at com.mysql.jdbc.Connection.<init>(Connection.java:1474)
	at com.mysql.jdbc.NonRegisteringDriver.connect(NonRegisteringDriver.java:264)
	at java.sql.DriverManager.getConnection(DriverManager.java:512)
	at java.sql.DriverManager.getConnection(DriverManager.java:193)
	at org.russ.jdbc.MySQL.main(MySQL.java:71)

** END NESTED EXCEPTION **

The odd thing is that when the same code is run on a Windows machine connecting to the database on the Mac it works. Also, I'm able to connect and select data via the "mysql" command line tool.

Any pointers would be appreciated. Thanks.
Russ

How to repeat:
Here's the Java code I'm using:

public class MySQL
{
    public static void main(String[] args)
    {
        Connection conn = null;
        Statement stmt = null;

        try
        {
            Class.forName("com.mysql.jdbc.Driver");
            conn = DriverManager.getConnection(
                        "jdbc:mysql://127.0.0.1/test?user=root&password=password");

            stmt = conn.createStatement();
            stmt.execute("Use dealbus");

            String sql = "select * from TestDOTypes;";
            ResultSet rs = stmt.executeQuery(sql);

            while ( rs.next() )
                System.out.println(rs.getMetaData().getColumnLabel(2) + ": " 
                        + rs.getString(2));
        }
        catch ( Exception e )
        {
            System.out.println("Error: " + e.getMessage());
        }
        finally
        {
            try { if ( conn != null ) conn.close(); } catch (SQLException e) {}
            try { if ( stmt != null ) stmt.close(); } catch (SQLException e) {}
        }
    }

}
[27 Sep 2005 9:08] Russ Fennell
Not sure why but there was a Socks proxy setting in a different profile/location that when removed fixed the problem. In theory each profile should be independent but apparently they are not.