JAVA编程中,mysql语句报错怎么解决?

报错代码:Truncated incorrect DOUBLE value: '??? ??'

public class MSUpdate {

private static DBSelect rid;

private static DBSelect idtype;

public void setDBSelect(DBSelect rid, DBSelect idtype){

this.rid=rid;

this.idtype=idtype;

}

public static void MSup(String[] args) {

MSDelete a=new MSDelete();

MSDelete b=new MSDelete();

DBSelect rid=new DBSelect();

DBSelect idtype=new DBSelect();

a.setDBSelect(rid);

b.setDBSelect(idtype);

MSConnection mysql = new MSConnection();

Connection con = mysql.getConnection();

PreparedStatement pst = null;

String sql = "update radius set username=?,value=?, where rid=" + rid + ",idtype=" + idtype;

try {

pst = con.prepareStatement(sql);

System.out.println("update");

pst.setString(1,"aaaa");

pst.setString(2, "12345");

pst.executeUpdate();

pst.close();

con.close();

} catch (SQLException e) {

e.printStackTrace();

}

}

}

错误:

com.mysql.jdbc.exceptions.jdbc4.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 'where rid=sql.DBSelect@b166b5,idtype=sql.DBSelect@cdfc9c' at line 1

at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)

at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)

at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)

at java.lang.reflect.Constructor.newInstance(Constructor.java:513)

at com.mysql.jdbc.Util.handleNewInstance(Util.java:411)

at com.mysql.jdbc.Util.getInstance(Util.java:386)

at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:1053)

at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:4096)

at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:4028)

at com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:2490)

at com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:2651)

at com.mysql.jdbc.ConnectionImpl.execSQL(ConnectionImpl.java:2734)

at com.mysql.jdbc.PreparedStatement.executeInternal(PreparedStatement.java:2155)

at com.mysql.jdbc.PreparedStatement.executeUpdate(PreparedStatement.java:2458)

at com.mysql.jdbc.PreparedStatement.executeUpdate(PreparedStatement.java:2375)

at com.mysql.jdbc.PreparedStatement.executeUpdate(PreparedStatement.java:2359)

at mysql.MSUpdate.MSup(MSUpdate.java:40):

温馨提示:答案为网友推荐,仅供参考
相似回答