You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@shardingsphere.apache.org by GitBox <gi...@apache.org> on 2021/07/07 11:22:50 UTC

[GitHub] [shardingsphere] terrymanu opened a new issue #11202: Connect proxy failure if using driver of MySQL 8 and prepared statement

terrymanu opened a new issue #11202:
URL: https://github.com/apache/shardingsphere/issues/11202


   When I used driver `8.0.11` of MySQL and enabled prepared statement(using `&useServerPrepStmts=true&cachePrepStmts=true` in JDBC URL) to connect proxy, the exception occur:
   
   ```log
   java.sql.SQLException: java.lang.ArrayIndexOutOfBoundsException: 1
   	at com.mysql.cj.jdbc.exceptions.SQLError.createSQLException(SQLError.java:127)
   	at com.mysql.cj.jdbc.exceptions.SQLError.createSQLException(SQLError.java:95)
   	at com.mysql.cj.jdbc.exceptions.SQLError.createSQLException(SQLError.java:87)
   	at com.mysql.cj.jdbc.exceptions.SQLError.createSQLException(SQLError.java:61)
   	at com.mysql.cj.jdbc.exceptions.SQLError.createSQLException(SQLError.java:71)
   	at com.mysql.cj.jdbc.ServerPreparedStatement.executeInternal(ServerPreparedStatement.java:420)
   	at com.mysql.cj.jdbc.ClientPreparedStatement.executeQuery(ClientPreparedStatement.java:1019)
   	at Main.executeQuery(Main.java:51)
   	at Main.main(Main.java:41)
   Caused by: java.lang.ArrayIndexOutOfBoundsException: 1
   	at com.mysql.cj.protocol.a.MergingColumnDefinitionFactory.createFromFields(MergingColumnDefinitionFactory.java:61)
   	at com.mysql.cj.protocol.a.ColumnDefinitionReader.read(ColumnDefinitionReader.java:80)
   	at com.mysql.cj.protocol.a.ColumnDefinitionReader.read(ColumnDefinitionReader.java:40)
   	at com.mysql.cj.protocol.a.NativeProtocol.read(NativeProtocol.java:1648)
   	at com.mysql.cj.protocol.a.BinaryResultsetReader.read(BinaryResultsetReader.java:70)
   	at com.mysql.cj.protocol.a.BinaryResultsetReader.read(BinaryResultsetReader.java:50)
   	at com.mysql.cj.protocol.a.NativeProtocol.read(NativeProtocol.java:1661)
   	at com.mysql.cj.protocol.a.NativeProtocol.readAllResults(NativeProtocol.java:1707)
   	at com.mysql.cj.ServerPreparedQuery.readExecuteResult(ServerPreparedQuery.java:419)
   	at com.mysql.cj.ServerPreparedQuery.serverExecute(ServerPreparedQuery.java:202)
   	at com.mysql.cj.jdbc.ServerPreparedStatement.serverExecute(ServerPreparedStatement.java:620)
   	at com.mysql.cj.jdbc.ServerPreparedStatement.executeInternal(ServerPreparedStatement.java:397)
   	... 3 more
   ```
   
   But driver `8.0.11` of MySQL `5.1.42` is fine.
   
   The test class is:
   
   ```java
   import java.sql.Connection;
   import java.sql.DriverManager;
   import java.sql.PreparedStatement;
   import java.sql.ResultSet;
   import java.sql.SQLException;
   import java.text.DecimalFormat;
   
   public final class Main {
       
       public static void main(final String[] args) throws ClassNotFoundException {
           String driverClassName = "com.mysql.jdbc.Driver";
           String url = "jdbc:mysql://localhost:3307/readwrite_splitting_db?serverTimezone=UTC&useSSL=false&useUnicode=true&characterEncoding=UTF-8&useServerPrepStmts=true&cachePrepStmts=true";
           String username = "root";
           String password = "root";
           String sql = "SELECT * FROM t_order WHERE order_id=?";
           Class.forName(driverClassName);
           try (Connection connection = DriverManager.getConnection(url, username, password);
                PreparedStatement preparedStatement = connection.prepareStatement(sql)
           ) {
               for (int i = 0; i < 10; i++) {
                   executeQuery(preparedStatement);
               }
           } catch (final SQLException ex) {
               ex.printStackTrace();
           }
       }
       
       private static void executeQuery(final PreparedStatement preparedStatement) throws SQLException {
           preparedStatement.setLong(1, 1);
           try (ResultSet resultSet = preparedStatement.executeQuery()) {
               while (resultSet.next()) {
                   resultSet.getObject(1);
               }
           }
       }
   }
   
   ```
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@shardingsphere.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [shardingsphere] tristaZero commented on issue #11202: Connect proxy failure if using driver of MySQL 8 and prepared statement

Posted by GitBox <gi...@apache.org>.
tristaZero commented on issue #11202:
URL: https://github.com/apache/shardingsphere/issues/11202#issuecomment-875534787


   Welcome, @donjuan6 


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@shardingsphere.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [shardingsphere] tristaZero closed issue #11202: Connect proxy failure if using driver of MySQL 8 and prepared statement

Posted by GitBox <gi...@apache.org>.
tristaZero closed issue #11202:
URL: https://github.com/apache/shardingsphere/issues/11202


   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@shardingsphere.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [shardingsphere] terrymanu commented on issue #11202: Connect proxy failure if using driver of MySQL 8 and prepared statement

Posted by GitBox <gi...@apache.org>.
terrymanu commented on issue #11202:
URL: https://github.com/apache/shardingsphere/issues/11202#issuecomment-877810500


   @donjuan6 Hi, after merge the PR #11265, the problem still not fixed yet.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@shardingsphere.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [shardingsphere] donjuan6 commented on issue #11202: Connect proxy failure if using driver of MySQL 8 and prepared statement

Posted by GitBox <gi...@apache.org>.
donjuan6 commented on issue #11202:
URL: https://github.com/apache/shardingsphere/issues/11202#issuecomment-875528680


   Can this issue be assigned to me?


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@shardingsphere.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [shardingsphere] terrymanu closed issue #11202: Connect proxy failure if using driver of MySQL 8 and prepared statement

Posted by GitBox <gi...@apache.org>.
terrymanu closed issue #11202:
URL: https://github.com/apache/shardingsphere/issues/11202


   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@shardingsphere.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [shardingsphere] terrymanu removed a comment on issue #11202: Connect proxy failure if using driver of MySQL 8 and prepared statement

Posted by GitBox <gi...@apache.org>.
terrymanu removed a comment on issue #11202:
URL: https://github.com/apache/shardingsphere/issues/11202#issuecomment-877810500


   @donjuan6 Hi, after merge the PR #11265, the problem still not fixed yet.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@shardingsphere.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org