0
我有在做同樣的事情,但在不同的表幾預處理語句:準備語句設置表NEM用於插入
ReportImageWrongLang = con.prepareStatement("INSERT INTO userReportedWrongLang VALUES (?,?,?) ON DUPLICATE KEY UPDATE UserId=UserID");
ReportImageProhibited = con.prepareStatement("INSERT INTO userReportedImages VALUES (?,?,?) ON DUPLICATE KEY UPDATE UserId=UserID");
ReportElse = con.prepareStatement(「INSERT INTO Reportelse VALUES(?,? ,?)ON DUPLICATE KEY UPDATE UserId = UserID「);
我根據我的java程序中的某些事件調用此語句。
我想改變這3語句到一個語句:
Report = con.prepareStatement("INSERT INTO ? VALUES (?,?,?) ON DUPLICATE KEY UPDATE UserId=UserID");
,並設置第一個參數是表名(Report.setString(1,表名))
但我m如果這個錯誤:
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 ''userreportedimages' VALUES ('3',331,1) ON DUPLICATE KEY UPDATE UserId=UserID' at line 1
有沒有辦法做到這一點?
好的,謝謝,我會再次重新考慮我的模式 – 2013-04-27 19:55:09