Mysql java executeUpdate error -
when use query have error
exception in thread "main" com.mysql.jdbc.exceptions.jdbc4.mysqlsyntaxerrorexception: have error in sql syntax; check manual corresponds mysql server version right syntax use near '12:04:44, 23-09-2014 12:04:44)' @ line 1
this code:
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 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 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();
where error?
i guessing username of type varchar? should add single quotes around it. same goes date.
stmt.executeupdate("insert 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();
Comments
Post a Comment