正确的语法使用附近'? Reg =?'

时间:2016-11-08 11:55:22

标签: java mysql sql

public static void updateData(Connection con, String make, String reg) {
    String selectString = "UPDATE Cars SET Make = ? WHERE Reg = ?";
    try
    {
        PreparedStatement pStmt = con.prepareStatement(selectString);
        pStmt.setString(1, make);
        pStmt.setString(2, reg);
        pStmt.executeUpdate(selectString);
        pStmt.close();

    }...

我为这段代码收到以下错误:

SQL Exception: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near '? WHERE Reg = ?' at line 1

如果有人可以帮助我,我会很感激。我已经四处寻找,但我的问题与我找到的解决方案完全不同。

1 个答案:

答案 0 :(得分:5)

使用针对<section class="contact"> <!-- Create three cells instead! --> <div class="adress"> <h4>abc</h4> <span> acbd<br> efgh </span> <span> tyre<br> asdsad<br> cxzcasd </span> </div> <div class="pic"> <img src="//placehold.it/100x100/fac" alt="map-ccc"> </div> <div class="map"> <img src="//placehold.it/500x300/fac" alt="google-map"> </div> </section>

的重载executeUpdate
PreparedStatements