我正在尝试使用以下代码更新mysql数据库 当我运行程序时,我在控制台
中收到以下错误错误:
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
'SET AVG_COST = 100000 , RWDS_INCENT = 200 , OTH_EXPENSES = 10000 ,
TRAVELLING_EX' at line 1
代码:
Class.forName("com.mysql.jdbc.Driver");
Connection con = DriverManager.getConnection(DB_URL,"root","root");
System.out.println("Remote DB connection established");
PreparedStatement statement=con.prepareStatement("UPDATE TBL_MONTHLY_EXPENSES_DETAILS " +
"SET AVG_COST = "+AVG_COST+" ," +
" RWDS_INCENT = "+RWDS_INCENT +" ,"+
" OTH_EXPENSES = "+OTH_EXPENSES+" ,"+
" TRAVELLING_EXPENSES = "+TRAVELLING_EXPENSES+" ,"+
" CLIENT_VISITS = "+CLIENT_VISITS+" ,"+
" REV_RECD = "+REV_RECD+" "
+" WHERE PJT_CODE = '"+PJT_CODE
+"' AND PJT_MONTH = '"+PJT_MONTH
+"' AND PJT_YEAR = '"+PJT_YEAR+"' "
);
statement.executeUpdate();
答案 0 :(得分:0)
TRAVELLING_EXPENSES
可能有问题。检查您要更新的值。