Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/mysql/61.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
从java更新mySQL数据库上的int_Java_Mysql - Fatal编程技术网

从java更新mySQL数据库上的int

从java更新mySQL数据库上的int,java,mysql,Java,Mysql,我在更新sql server时遇到问题。级别是普通键,idScore是主键。这些级别是服务器上的整数。我已经设法获得了这些级别,但我一直坚持更新到新的值有一段时间了。“uCon”正在工作,它已登录到服务器。可以执行其他命令。必须是sql语句。允许登录的acc进行更新和选择。可以换成ofc 在where子句之前有一个多余的逗号(,)-您应该删除它: String sql = "UPDATE phantom.BoulderDash SET level1 = "+highScore1+", "

我在更新sql server时遇到问题。级别是普通键,idScore是主键。这些级别是服务器上的整数。我已经设法获得了这些级别,但我一直坚持更新到新的值有一段时间了。“uCon”正在工作,它已登录到服务器。可以执行其他命令。必须是sql语句。允许登录的acc进行更新和选择。可以换成ofc


where
子句之前有一个多余的逗号(
)-您应该删除它:

String sql = "UPDATE phantom.BoulderDash SET level1 = "+highScore1+", "
                                                  + "level2 = "+highScore2+", "
                                                  + "level3 = "+highScore3+" " // No comma here
                                                  + "WHERE idScore = '" + userName + "';";

删除逗号并确保
WHERE
前面有空格


对于此类调试问题,请考虑添加一个
System.out.println(“sql=“+sql”)


这样您就可以看到将要提交到数据库的实际sql语句。

那么问题出在哪里?你有错误吗?“你的SQL语法有错误;”但我找不到哪里出了问题。。。
String sql = "UPDATE phantom.BoulderDash SET level1 = "+highScore1+", "
                                                  + "level2 = "+highScore2+", "
                                                  + "level3 = "+highScore3+" " // No comma here
                                                  + "WHERE idScore = '" + userName + "';";