0
當我使用此查詢我有這樣的錯誤在線程mysql的java的executeUpdate的錯誤
異常「主」 com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException:您在您的SQL語法有錯誤 ;檢查對應於您 MySQL服務器版本正確的語法附近'12使用手冊:04:44), 23-09-2014 12時04分44秒」,在1號線
這是代碼:
SimpleDateFormat sdf = new SimpleDateFormat("dd-MM-yyyy HH:mm:ss"); // creo l'oggetto
String dataStr = sdf.format(new Date());
System.out.println(dataStr);
// eseguo una query
/*stmt.executeQuery("INSERT INTO incomeCalc(c_timestamp, parent_uid, uid, status, username, password, token, enable_webservices, "
+ "webservices_ip, name, mobile, email, sender, footer, address, city, state, country, zipcode, credit, datetime_timezone,"
+ "lang uage_module, fwd_to_mobile, fwd_to_email, fwd_to_inbox, replace_zero, plus_ sign_remove, plus_sign_add, "
+ "send_as_unicode, local_length, register_datetime, lastupdate_datetime,) " */
stmt.executeUpdate("INSERT INTO playsms_tblUser(parent_uid, status, username, password, token, enable_webservices, credit, datetime_timezone, language_module, register_datetime, lastupdate_datetime)"
+ "VALUES (1, 4, "+user+", MD5("+password+"), MD5("+password+"), 1, "+initialCredit+", +0100, en_US, "+dataStr+", "+dataStr+")");
db.close();
錯誤在哪裏?
爲什麼不使用* PreparedSatement *?那麼你不需要進行報價和格式。 – agad 2014-09-23 10:20:23
完美,我用PreparedStatement和它的作品 – luca 2014-09-23 10:45:37