mysql jdbc got ArrayIndexOutOfBoundsException when database name length = 9

Posted by Thang Hoang on Server Fault See other posts from Server Fault or by Thang Hoang
Published on 2012-11-20T04:34:39Z Indexed on 2012/11/20 5:01 UTC
Read the original article Hit count: 638

Filed under:
|

this code below will throw : Exception in thread "main" java.sql.SQLException: Unable to connect to any hosts due to exception: java.lang.ArrayIndexOutOfBoundsException: 40

mysql 5.1, jdbc driver 5.1.21

if I change connection string to any database have name's lengh != 9, it will pass to print 'connected'. or I create other database as '123456789' it throw same exception.

I connect to other database on amazon s3, that have same name length, it throw java.lang.ArrayIndexOutOfBoundsException: 43. this database version is 'mysql Ver 14.14 Distrib 5.5.28, for debian-linux-gnu (i686) using readline 6.2 '

any idea of this weird mysql behavior, thanks


public class MysqlConnection {
    public static void main(String[] args) throws Exception {
        Connection conn = null;         
        String userName = "root";
        String password = "123456";
        String url = "jdbc:mysql://localhost:3306/test12345";
        Class.forName ("com.mysql.jdbc.Driver").newInstance ();

        conn = DriverManager.getConnection (url,userName, password);
        System.out.println ("Connected");

    }

}

© Server Fault or respective owner

Related posts about mysql

Related posts about jdbc