鍍金池/ 問(wèn)答/數(shù)據(jù)庫(kù)/ java項(xiàng)目中sql語(yǔ)句的問(wèn)題

java項(xiàng)目中sql語(yǔ)句的問(wèn)題

package Process;
import java.sql.Connection;
import java.sql.SQLException;
import java.sql.Statement;
import com.sqldata;
public class ChangeNumber {


 public static void Changeusernumber(String userid,int newnumber)
 {
     Connection conn=sqldata.SQLConn();
     try {
         if(conn!=null){
   System.out.println("數(shù)據(jù)庫(kù)鏈接成功!");
   Statement state=conn.createStatement();
   String sql = "update 用戶  set 用戶積分="+newnumber+" where 用戶ID="+"'"+userid+"'";
   state.executeUpdate(sql);
  System.out.println("用戶積分更新");
         }else
         {
             System.out.println("數(shù)據(jù)庫(kù)鏈接失??!");
         }
     
    }
    catch (SQLException e) {
      e.printStackTrace();
    }
 }

}

運(yùn)行后出現(xiàn)這這樣的錯(cuò)誤提示,麻煩大家看看上面的sql語(yǔ)句哪里出現(xiàn)了問(wèn)題?
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 '用戶ID='13831880053'' at line 1

————————————————————————————————————————

第一次修改
各位大佬們,我把所有的表名、用戶名都修改為了英文的,但是依然出現(xiàn)這個(gè)錯(cuò)誤。下面是修改后的代碼:
package Process;
import java.sql.Connection;
import java.sql.SQLException;
import java.sql.Statement;
import com.sqldata;
public class ChangeNumber {


 public static void Changeusernumber(String userid,int newnumber)
 {
     Connection conn=sqldata.SQLConn();
     try {
         if(conn!=null){
   System.out.println("數(shù)據(jù)庫(kù)鏈接成功!");
   Statement state=conn.createStatement();
   String sql = "update user  set usernumber="+newnumber+"where userID='"+userid+"'";
   state.executeUpdate(sql);
  System.out.println("用戶積分更新");
         }else
         {
             System.out.println("數(shù)據(jù)庫(kù)鏈接失??!");
         }
     
    }
    catch (SQLException e) {
      e.printStackTrace();
    }
 }

}
——————錯(cuò)誤提示
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 'userID='13831880053'' at line 1

回答
編輯回答
怣人

哇 中文表名 ,第一次見(jiàn)

2017年1月21日 19:35
編輯回答
念初

字符集問(wèn)題?不得不吐槽一下,用中文做表名和字段名真是自找麻煩啊……

2017年5月8日 02:35
編輯回答
有你在

把sql打印出來(lái)就知道哪里有問(wèn)題了,單看sql語(yǔ)法是沒(méi)問(wèn)題的,跟是不是漢字沒(méi)有關(guān)系,懷疑是中間有全半角的輸入問(wèn)題

2017年10月10日 23:18
編輯回答
瘋子范

表名和字段名加個(gè)``試下..

2018年8月6日 08:10