Bug #77649 | URL start with word "address",JDBC can't parse the "host:port" Correctly | ||
---|---|---|---|
Submitted: | 8 Jul 2015 5:48 | Modified: | 13 Sep 2016 21:49 |
Reporter: | guo Miner | Email Updates: | |
Status: | Closed | Impact on me: | |
Category: | Connector / J | Severity: | S2 (Serious) |
Version: | since 5.1.34, 5.1.33, 5.1.35, 5.1.36 | OS: | Any |
Assigned to: | Filipe Silva | CPU Architecture: | Any |
Tags: | JDBC parseHostPortPair "address" |
[8 Jul 2015 5:48]
guo Miner
[8 Jul 2015 5:49]
guo Miner
SORRY ,repeat code should like this: 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", "appusr"); pro.setProperty("password", "appusr"); 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(); } }
[8 Jul 2015 8:03]
MySQL Verification Team
Hello guo Miner, Thank you for the report and test case. Thanks, Umesh
[13 Sep 2016 21:49]
Daniel So
Posted by developer: Added the following entry to the C/J 5.1.40 changelog: "Connector/J could not parse the host name and port number from connection URLS staring with the word “address,” resulting in an UnknownHostException. This was because the URLs were being interpreted incorrectly as using the alternate URL format, which starts with “address=” This patch fixes the parser for proper interpretation of the URL in the situation. "