Simbafa opened a new issue #6527:
URL: https://github.com/apache/shardingsphere/issues/6527


   ## Bug Report
   
   ### Which version of ShardingSphere did you use?
   The latest version: Shardingsphere-ui-4.1.1
   ### Which project did you use? ShardingSphere-JDBC or ShardingSphere-Proxy?
   ShardingSphere-Proxy
   ### Expected behavior
   limit/offset can use variants.
   ### Actual behavior
   ERROR: Statement parameter 1 not set., SqlState: S1009, code:0
   ### Reason analyze (If you can)
   I searched internet, someone says that Mysql does not support limit variant 
before 5.5 version.
   
   ### Steps to reproduce the behavior, such as: SQL to execute, sharding rule 
configuration, when exception occur etc.
   
   ### Example codes for reproduce this issue (such as a github link).
   ```java
       static void testLimit() throws Exception {
           Class.forName("com.mysql.jdbc.Driver");
           String url 
="jdbc:mysql://192.168.1.46:3307/test?user=root&password=test&serverTimezone=UTC&useSSL=false&useServerPrepStmts=true";
           //url = 
"jdbc:mysql://192.168.0.108:3306/test?user=root&password=test&zeroDateTimeBehavior=convertToNull&useServerPrepStmts=true";
                                                                                
                                                    
           //String user= 
java.util.Base64.getEncoder().encodeToString(url.getBytes("UTF-8"));
           //url 
="jdbc:mysql://192.168.1.46:3307/test?user="+user+"&password=test&useServerPrepStmts=true";
           Connection conn = DriverManager.getConnection(url);
           List<Object> params = new ArrayList<Object>();
           params.add(20); params.add(0); 
           selectSql(conn, "select * from sys_migrate ", params, 0); 
           selectSql(conn, "select * from sys_migrate limit ? offset ?", 
params, 2); 
       }   
   
   
       static void selectSql(Connection conn, String sql, List<Object> 
paramValues, int paramValuesCount) throws SQLException {
           PreparedStatement stmt = null;
           try {
               System.out.println("selectSql PREPARE: " + sql);
               stmt = conn.prepareStatement(sql);
               paramValuesCount = paramValues == null ? 0 : paramValuesCount;
               for (int i = 0; i < paramValuesCount; i++) {
                   stmt.setObject(i + 1, paramValues.get(i));
               }
               ResultSet rs = stmt.executeQuery();
               ResultSetMetaData rsmd = rs.getMetaData();
               int count = rsmd.getColumnCount();
               while (rs.next()) {
                   for (int i = 1; i <= count; i++) {
                       String key = rsmd.getColumnLabel(i);
                       Object value = rs.getObject(i);
                       System.out.println("key:" + key + ", value:" + 
(value==null?"null":value));
                   }
               }
               rs.close();
           } catch (SQLException e) {
               System.out.println("===Error:" + e.getMessage()+", SqlState: " + 
e.getSQLState() + ", code:" + e.getErrorCode());
           } finally {
               if (stmt != null) {
                   stmt.close();
               }
           }
       }
   
   
   ```


----------------------------------------------------------------
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.

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


Reply via email to