Bug #1570 Communication failure during handshake.
Submitted: 16 Oct 2003 7:19 Modified: 16 Oct 2003 8:01
Reporter: Colin Kriwox Email Updates:
Status: Closed Impact on me:
None 
Category:Connector / J Severity:S3 (Non-critical)
Version:3.1.0-alpha OS:Linux (Red Hat 9)
Assigned to: CPU Architecture:Any

[16 Oct 2003 7:19] Colin Kriwox
Description:
In Red Hat 9.0 the computer name is defaulted to localhost.localdomain, which might be significant. I have setup MySQL 4.1.0-alpha on this machine, and I am attempting to connect using the Java LoadClass and getConnection. There is a user that has been granted all privileges to everything from anywhere.

GRANT ALL PRIVILEGES ON *.* TO superuser@'%' IDENTIFIED BY 'mypassword';

I can test that this user has access by typing 
shell> mysqlpath/bin/mysql -u superuser -p

The problem occurs when I try to connect via JConnector V3.1.0-alpha to a database that is more than 4 characters long (e.g. myexample). The error message is "Communication failure during handshake. Message from server: 'Unkown database 'myex'". This appears to be a permission problem except that I can connect to any 4 or less character databases (e.g. "test","user","log"...). 

How to repeat:
import java.sql.Connection; 
import java.sql.DriverManager; 
import java.sql.SQLException; 
import java.sql.Statement;
import java.sql.ResultSet;

public class JDBCTest { 
public static void main(String[] args) { 
try { 
Class.forName("com.mysql.jdbc.Driver").newInstance(); 
Connection conn =
DriverManager.getConnection("jdbc:mysql://localhost/myexample",
"superuser", "mypassword");
...

Suggested fix:
I'm not sure if the localhost.localdomain is too long and causing JConnector to truncat the database names to 4 characters. If this is a setup error I apologize for submitting this as a bug.

Thank you,
Colin Kriwox
[16 Oct 2003 8:01] Mark Matthews
Thank you for your bug report. This issue has been committed to our
source repository of that product and will be incorporated into the
next release.

If necessary, you can access the source repository and build the latest
available version, including the bugfix, yourself. More information 
about accessing the source trees is available at
    http://www.mysql.com/doc/en/Installing_source_tree.html
[16 Oct 2003 8:02] Mark Matthews
See http://downloads.mysql.com/snapshots.php for a nightly release of Connector/J 3.1 which fixes this problem (it's been fixed for quite some time, but we're holding back a release of Connector/J 3.1 to coincide with the release of MySQL-4.1.1 ALPHA).
[16 Oct 2003 10:12] Colin Kriwox
Mark,

Thanks for your help. I was not aware of the nightly releases. 

Colin Kriwox