com.mysql.jdbc.exceptions.MySQLSyntaxErrorException错误

时间:2024-01-07 11:17:02
com.mysql.jdbc.exceptions.MySQLSyntaxErrorException: You have an error in your SQL syntax; check the manual that corresponds to your MySQL
server version for the right syntax to use near 'receiverTel='123131' payment=0,time ='2015-04-10 10:14', tradeTime='',sndgoodsTi' at line 1
at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:936)
at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:2985)
at com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:1631)
at com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:1723)
at com.mysql.jdbc.Connection.execSQL(Connection.java:3283)
at com.mysql.jdbc.PreparedStatement.executeInternal(PreparedStatement.java:1332)
at com.mysql.jdbc.PreparedStatement.executeUpdate(PreparedStatement.java:1604)
at com.mysql.jdbc.PreparedStatement.executeUpdate(PreparedStatement.java:1519)

这是因为receiverTel与payment少了一个逗号,

String sql = "update em_order set orderId=?,userId=?,receiverName=?,receiverAddress=?,postCode=? receiverTel=?,payment=?,time =?, tradeTime=?,
sndgoodsTime=? state=? where id =? ";
JDBCUtils.upDate(sql,o.getOrderId(),o.getUserId(),o.getReceiverName(),o.getReceiverAddress(),o.getPostCode(),o.getReceiverTel(),
o.getPayment(),o.getTime(),o.getTradeTime(),o.getSndgoodsTime(),o.getState(),o.getId());
java.sql.SQLException: Parameter index out of range (11 > number of paramete,which is 0);

这个错误是因为少写了一个?,在查询数据库代码中。