Bug #91547 MySQL Connector/J 5.1.46 produce an NullPointerException
Description:
when i'am using Connector/J 5.1.46 loadblance mode,but it produce an NullPointerException.
How to repeat:
1. jdbc url is "jdbc:mysql:loadbalance://127.0.0.1:5061,127.0.0.1:5062,127.0.0.1:5063/base?loadBalanceAutoCommitStatementThreshold=3"
2.code like:
Connection connection=druid.getConnection();
JdbcUtils.executeQuery(connection,"select * from customer",new ArrayList<Object>())
JdbcUtils.close(connection);
3.error info
Exception in thread "main" java.sql.SQLException: Unexpected exception encountered during query.
at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:965)
at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:898)
at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:887)
at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:861)
at com.mysql.jdbc.ConnectionImpl.execSQL(ConnectionImpl.java:2523)
at com.mysql.jdbc.MultiHostMySQLConnection.execSQL(MultiHostMySQLConnection.java:158)
at com.mysql.jdbc.PreparedStatement.executeInternal(PreparedStatement.java:1858)
at com.mysql.jdbc.PreparedStatement.executeQuery(PreparedStatement.java:1966)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:497)
at com.mysql.jdbc.MultiHostConnectionProxy$JdbcInterfaceProxy.invoke(MultiHostConnectionProxy.java:108)
at com.sun.proxy.$Proxy17.executeQuery(Unknown Source)
at com.alibaba.druid.pool.DruidPooledPreparedStatement.executeQuery(DruidPooledPreparedStatement.java:228)
at com.alibaba.druid.util.JdbcUtils.executeQuery(JdbcUtils.java:695)
at pool.Test.main(Test.java:32)
Caused by: java.lang.NullPointerException
at com.mysql.jdbc.StringUtils.startsWithIgnoreCase(StringUtils.java:1485)
at com.mysql.jdbc.StringUtils.startsWithIgnoreCase(StringUtils.java:1500)
at com.mysql.jdbc.LoadBalancedAutoCommitInterceptor.postProcess(LoadBalancedAutoCommitInterceptor.java:79)
at com.mysql.jdbc.MysqlIO.invokeStatementInterceptorsPost(MysqlIO.java:2888)
at com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:2811)
at com.mysql.jdbc.ConnectionImpl.execSQL(ConnectionImpl.java:2486)
... 12 more
Suggested fix:
line 79 in com.mysql.jdbc.LoadBalancedAutoCommitInterceptor
code " if (!this.countStatements || StringUtils.startsWithIgnoreCase(sql, "SET") || StringUtils.startsWithIgnoreCase(sql, "SHOW")) {"
shoud add "sql!=null" :
"if (!this.countStatements || (sql!=null&&StringUtils.startsWithIgnoreCase(sql, "SET")) || (sql!=null&&StringUtils.startsWithIgnoreCase(sql, "SHOW")) {"
Portions of this website are copyright © 2001, 2002 The PHP Group
Page generated in 0.052 sec. using MySQL 8.4.7-u6-cloud
Timestamp references displayed by the system are UTC.
Content reproduced on this site is the property of the
respective copyright holders.
It is not reviewed in advance
by Oracle and does not necessarily represent the opinion of
Oracle or any other party.
Description: when i'am using Connector/J 5.1.46 loadblance mode,but it produce an NullPointerException. How to repeat: 1. jdbc url is "jdbc:mysql:loadbalance://127.0.0.1:5061,127.0.0.1:5062,127.0.0.1:5063/base?loadBalanceAutoCommitStatementThreshold=3" 2.code like: Connection connection=druid.getConnection(); JdbcUtils.executeQuery(connection,"select * from customer",new ArrayList<Object>()) JdbcUtils.close(connection); 3.error info Exception in thread "main" java.sql.SQLException: Unexpected exception encountered during query. at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:965) at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:898) at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:887) at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:861) at com.mysql.jdbc.ConnectionImpl.execSQL(ConnectionImpl.java:2523) at com.mysql.jdbc.MultiHostMySQLConnection.execSQL(MultiHostMySQLConnection.java:158) at com.mysql.jdbc.PreparedStatement.executeInternal(PreparedStatement.java:1858) at com.mysql.jdbc.PreparedStatement.executeQuery(PreparedStatement.java:1966) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:497) at com.mysql.jdbc.MultiHostConnectionProxy$JdbcInterfaceProxy.invoke(MultiHostConnectionProxy.java:108) at com.sun.proxy.$Proxy17.executeQuery(Unknown Source) at com.alibaba.druid.pool.DruidPooledPreparedStatement.executeQuery(DruidPooledPreparedStatement.java:228) at com.alibaba.druid.util.JdbcUtils.executeQuery(JdbcUtils.java:695) at pool.Test.main(Test.java:32) Caused by: java.lang.NullPointerException at com.mysql.jdbc.StringUtils.startsWithIgnoreCase(StringUtils.java:1485) at com.mysql.jdbc.StringUtils.startsWithIgnoreCase(StringUtils.java:1500) at com.mysql.jdbc.LoadBalancedAutoCommitInterceptor.postProcess(LoadBalancedAutoCommitInterceptor.java:79) at com.mysql.jdbc.MysqlIO.invokeStatementInterceptorsPost(MysqlIO.java:2888) at com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:2811) at com.mysql.jdbc.ConnectionImpl.execSQL(ConnectionImpl.java:2486) ... 12 more Suggested fix: line 79 in com.mysql.jdbc.LoadBalancedAutoCommitInterceptor code " if (!this.countStatements || StringUtils.startsWithIgnoreCase(sql, "SET") || StringUtils.startsWithIgnoreCase(sql, "SHOW")) {" shoud add "sql!=null" : "if (!this.countStatements || (sql!=null&&StringUtils.startsWithIgnoreCase(sql, "SET")) || (sql!=null&&StringUtils.startsWithIgnoreCase(sql, "SHOW")) {"