Bug #77650 URL start with word "address",JDBC can't parse the "host:port" Correctly.
Submitted: 8 Jul 2015 5:56 Modified: 8 Jul 2015 8:05
Reporter: guo Miner Email Updates:
Status: Duplicate Impact on me:
None 
Category:Connector / J Severity:S2 (Serious)
Version:since 5.1.34 OS:Any
Assigned to: CPU Architecture:Any
Tags: JDBC parseHostPortPair "address"

[8 Jul 2015 5:56] guo Miner
Description:
When the database connection url start with the word "address",the JDBC Driver can't parse the "host:port" Correctly.
For example: 
 my db connection url is :addressXXX.xxx.com:3306,JDBC Driver will report:
Caused by: java.net.UnknownHostException: addressXXX.xxx.com:3306
	at java.net.Inet6AddressImpl.lookupAllHostAddr(Native Method)
	at java.net.InetAddress$1.lookupAllHostAddr(InetAddress.java:883)
	at java.net.InetAddress.getAddressFromNameService(InetAddress.java:1236)
	at java.net.InetAddress.getAllByName0(InetAddress.java:1187)
	at java.net.InetAddress.getAllByName(InetAddress.java:1117)
	at java.net.InetAddress.getAllByName(InetAddress.java:1053)
	at com.mysql.jdbc.StandardSocketFactory.connect(StandardSocketFactory.java:190)
	at com.mysql.jdbc.MysqlIO.<init>(MysqlIO.java:297)

How to repeat:
import java.net.SocketException;
import java.net.UnknownHostException;
import java.sql.Connection;
import java.sql.Driver;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import java.util.Properties;

public class tmpjdbc {
	public static void main(String[] args) throws SQLException, ClassNotFoundException, UnknownHostException, SocketException {
		

		Class.forName("com.mysql.jdbc.Driver");

		Properties pro = new Properties();
		pro.setProperty("user", "XXX");
		pro.setProperty("password", "XXX");

		Driver driver = new com.mysql.jdbc.Driver();

		Connection connection1 = driver.connect("jdbc:mysql://addressxxx.com:3306/?zeroDateTimeBehavior=convertToNull", pro);
		Statement statement1 = connection1.createStatement();

		ResultSet _result = statement1.executeQuery("select 1");
		while (_result.next()) {
			System.out.println(_result.getInt(1));
		}

		connection1.close();
	}
}

Suggested fix:
change the method parseHostPortPair of  com/mysql/jdbc/NonRegisteringDriver.java  from

protected static String[] parseHostPortPair(String hostPortPair) throws SQLException {

        String[] splitValues = new String[2];

        if (StringUtils.startsWithIgnoreCaseAndWs(hostPortPair, "address")) {
            splitValues[HOST_NAME_INDEX] = hostPortPair.trim();
            splitValues[PORT_NUMBER_INDEX] = null;

            return splitValues;
        }

.....

to

protected static String[] parseHostPortPair(String hostPortPair) throws SQLException {

        String[] splitValues = new String[2];

        if (StringUtils.startsWithIgnoreCaseAndWs(hostPortPair, "address=")) {
            splitValues[HOST_NAME_INDEX] = hostPortPair.trim();
            splitValues[PORT_NUMBER_INDEX] = null;

            return splitValues;
        }
.....
[8 Jul 2015 8:05] MySQL Verification Team
Please do not submit the same bug more than once. An existing bug report Bug #77649 already describes this very problem. Even if you feel that your issue is somewhat different, the resolution is likely
to be the same. Because of this, we hope you add your comments to the original bug instead.

Thank you for your interest in MySQL.