<h2 dir="auto">Bug Report</h2>
<h3 dir="auto">Which version of ShardingSphere did you use?</h3>
<p dir="auto">5.0.0-RC1-SNAPSHOT</p>
<h3 dir="auto">Which project did you use? ShardingSphere-JDBC or ShardingSphere-Proxy?</h3>
<p dir="auto">ShardingSphere-Proxy</p>
<h3 dir="auto">Expected behavior</h3>
<p dir="auto">Sql could be executed correctly, just like MySQL 5.7 server.</p>
<h3 dir="auto">Actual behavior</h3>
<p dir="auto">Exception thrown:</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="Exception in thread &quot;main&quot; java.sql.SQLException: Statement parameter 5 not set.
	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.ServerPreparedStatement.serverExecute(ServerPreparedStatement.java:1174)
	at com.mysql.jdbc.ServerPreparedStatement.executeInternal(ServerPreparedStatement.java:787)
	at com.mysql.jdbc.PreparedStatement.executeUpdateInternal(PreparedStatement.java:2133)
	at com.mysql.jdbc.PreparedStatement.executeUpdateInternal(PreparedStatement.java:2067)
	at com.mysql.jdbc.PreparedStatement.executeLargeUpdate(PreparedStatement.java:5175)
	at com.mysql.jdbc.PreparedStatement.executeUpdate(PreparedStatement.java:2052)"><pre class="notranslate"><code class="notranslate">Exception in thread "main" java.sql.SQLException: Statement parameter 5 not set.
	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.ServerPreparedStatement.serverExecute(ServerPreparedStatement.java:1174)
	at com.mysql.jdbc.ServerPreparedStatement.executeInternal(ServerPreparedStatement.java:787)
	at com.mysql.jdbc.PreparedStatement.executeUpdateInternal(PreparedStatement.java:2133)
	at com.mysql.jdbc.PreparedStatement.executeUpdateInternal(PreparedStatement.java:2067)
	at com.mysql.jdbc.PreparedStatement.executeLargeUpdate(PreparedStatement.java:5175)
	at com.mysql.jdbc.PreparedStatement.executeUpdate(PreparedStatement.java:2052)
</code></pre></div>
<h3 dir="auto">Reason analyze (If you can)</h3>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="mysql-connector-java-5.1.48
ServerPreparedStatement.java, serverPrepare(String sql)
                Buffer prepareResultPacket = mysql.sendCommand(MysqlDefs.COM_PREPARE, sql, null, false, characterEncoding, 0);

                if (this.connection.versionMeetsMinimum(4, 1, 1)) {
                    // 4.1.1 and newer use the first byte as an 'ok' or 'error' flag, so move the buffer pointer past it to start reading the statement id.
                    prepareResultPacket.setPosition(1);
                } else {
                    // 4.1.0 doesn't use the first byte as an 'ok' or 'error' flag
                    prepareResultPacket.setPosition(0);
                }

                this.serverStatementId = prepareResultPacket.readLong();
                this.fieldCount = prepareResultPacket.readInt();
                this.parameterCount = prepareResultPacket.readInt();
                this.parameterBindings = new BindValue[this.parameterCount];
this.parameterCount is 5, which is from proxy server side, but it's 4 in fact"><pre class="notranslate"><code class="notranslate">mysql-connector-java-5.1.48
ServerPreparedStatement.java, serverPrepare(String sql)
                Buffer prepareResultPacket = mysql.sendCommand(MysqlDefs.COM_PREPARE, sql, null, false, characterEncoding, 0);

                if (this.connection.versionMeetsMinimum(4, 1, 1)) {
                    // 4.1.1 and newer use the first byte as an 'ok' or 'error' flag, so move the buffer pointer past it to start reading the statement id.
                    prepareResultPacket.setPosition(1);
                } else {
                    // 4.1.0 doesn't use the first byte as an 'ok' or 'error' flag
                    prepareResultPacket.setPosition(0);
                }

                this.serverStatementId = prepareResultPacket.readLong();
                this.fieldCount = prepareResultPacket.readInt();
                this.parameterCount = prepareResultPacket.readInt();
                this.parameterBindings = new BindValue[this.parameterCount];
this.parameterCount is 5, which is from proxy server side, but it's 4 in fact
</code></pre></div>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="org.apache.shardingsphere.proxy.frontend.mysql.command.query.binary.prepare.MySQLComStmtPrepareExecutor.java, execute()
        SQLStatement sqlStatement = schema.getRuntimeContext().getSqlParserEngine().parse(packet.getSql(), true);
        if (!MySQLComStmtPrepareChecker.isStatementAllowed(sqlStatement)) {
            result.add(new MySQLErrPacket(++currentSequenceId, MySQLServerErrorCode.ER_UNSUPPORTED_PS));
            return result;
        }
        int parametersCount = sqlStatement.getParameterCount();
parametersCount is 5 after parsing"><pre class="notranslate"><code class="notranslate">org.apache.shardingsphere.proxy.frontend.mysql.command.query.binary.prepare.MySQLComStmtPrepareExecutor.java, execute()
        SQLStatement sqlStatement = schema.getRuntimeContext().getSqlParserEngine().parse(packet.getSql(), true);
        if (!MySQLComStmtPrepareChecker.isStatementAllowed(sqlStatement)) {
            result.add(new MySQLErrPacket(++currentSequenceId, MySQLServerErrorCode.ER_UNSUPPORTED_PS));
            return result;
        }
        int parametersCount = sqlStatement.getParameterCount();
parametersCount is 5 after parsing
</code></pre></div>
<h3 dir="auto">Steps to reproduce the behavior, such as: SQL to execute, sharding rule configuration, when exception occur etc.</h3>
<p dir="auto">Run sql via jdbc:</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="jdbcUrl:
jdbc:mysql://127.0.0.1:3307/sharding_db?serverTimezone=UTC&amp;useSSL=false&amp;useServerPrepStmts=true&amp;cachePrepStmts=true

try (PreparedStatement statement = connection.prepareStatement(
        &quot;insert into t_order (order_id, user_id, status) values (?, ?, ?) ON DUPLICATE KEY UPDATE status = ?&quot;)) {
	statement.setInt(1, orderId);
	statement.setInt(2, userId);
	statement.setString(3, status);
	statement.setString(4, &quot;DUPLICATED&quot;);
	statement.executeUpdate();
}"><pre class="notranslate"><code class="notranslate">jdbcUrl:
jdbc:mysql://127.0.0.1:3307/sharding_db?serverTimezone=UTC&amp;useSSL=false&amp;useServerPrepStmts=true&amp;cachePrepStmts=true

try (PreparedStatement statement = connection.prepareStatement(
        "insert into t_order (order_id, user_id, status) values (?, ?, ?) ON DUPLICATE KEY UPDATE status = ?")) {
	statement.setInt(1, orderId);
	statement.setInt(2, userId);
	statement.setString(3, status);
	statement.setString(4, "DUPLICATED");
	statement.executeUpdate();
}
</code></pre></div>
<h3 dir="auto">Example codes for reproduce this issue (such as a github link).</h3>
<p dir="auto">Please answer these questions before submitting your issue. Thanks!</p>
<h3 dir="auto">Which version of Sharding-Jdbc do you using?</h3>
<p dir="auto">2.0.2</p>
<h3 dir="auto">Expected behavior</h3>
<p dir="auto">DDL 语句只在master数据源执行</p>
<h3 dir="auto">Actual behavior</h3>
<p dir="auto">DDL在master与slave都会执行导致duplication issue</p>
<h3 dir="auto">Steps to reproduce the behavior</h3>
<p dir="auto"><a class="user-mention notranslate" data-hovercard-type="user" data-hovercard-url="/users/terrymanu/hovercard" data-octo-click="hovercard-link-click" data-octo-dimensions="link_type:self" href="https://github.com/terrymanu">@terrymanu</a> <a class="issue-link js-issue-link" data-error-text="Failed to load title" data-id="292091697" data-permission-text="Title is private" data-url="https://github.com/apache/shardingsphere/issues/581" data-hovercard-type="issue" data-hovercard-url="/apache/shardingsphere/issues/581/hovercard" href="https://github.com/apache/shardingsphere/issues/581">#581</a> <a class="issue-link js-issue-link" data-error-text="Failed to load title" data-id="290369264" data-permission-text="Title is private" data-url="https://github.com/apache/shardingsphere/issues/570" data-hovercard-type="issue" data-hovercard-url="/apache/shardingsphere/issues/570/hovercard" href="https://github.com/apache/shardingsphere/issues/570">#570</a></p>
<ol dir="auto">
<li>
<p dir="auto">在OrderMapper.xml中加一个方法，<br>
<br>
ALTER TABLE t_order<br>
ADD COLUMN order_no VARCHAR(50) NULL COMMENT 'order no , seq rule: random(10)+timestamp' AFTER status;</p>
 
</li>
</ol>
<p dir="auto">对应的<br>
void alterTable();</p>
<ol start="2" dir="auto">
<li>
<p dir="auto">demoservice添加测试方法</p>
<p dir="auto">public void testAlterOrder() {<br>
System.out.println("test alter tables started ...........");<br>
orderRepository.alterTable();<br>
}</p>
</li>
<li>
<p dir="auto">SpringBootDataMybatisMain  中添加调用<br>
applicationContext.getBean(DemoService.class).testAlterOrder();</p>
</li>
</ol>
<p dir="auto"><a target="_blank" rel="noopener noreferrer nofollow" href="https://user-images.githubusercontent.com/8716969/35478797-a28ef772-0421-11e8-9b25-c89be9e6da4f.png"><img src="https://user-images.githubusercontent.com/8716969/35478797-a28ef772-0421-11e8-9b25-c89be9e6da4f.png" alt="image" style="max-width: 100%;"></a></p>
<p dir="auto"><a target="_blank" rel="noopener noreferrer nofollow" href="https://user-images.githubusercontent.com/8716969/35478808-245293cc-0422-11e8-9b42-6aa2f469c53a.png"><img src="https://user-images.githubusercontent.com/8716969/35478808-245293cc-0422-11e8-9b42-6aa2f469c53a.png" alt="image" style="max-width: 100%;"></a></p>
<h3 dir="auto">Please provide the reproduce example codes (such as github link)</h3>
<p dir="auto">Code should based on <a href="https://github.com/shardingjdbc/sharding-jdbc-example">https://github.com/shardingjdbc/sharding-jdbc-example</a><br>
基于 example中  sharding-jdbc-spring-boot-data-mybatis-example</p>