在java中遇到的MySQL存储问题,String time = "2018-12-09 10:27:25";
String sql = "insert into flux values('11','22','2018-12-09 10:27:25','44') ";
这样可以插入,String time = "2018-12-09 10:27:25";
String sql = "insert into flux values('11','22',"+time+",'44') ";
con.executeSql(sql);却显示错误,错误信息: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 '10:27:25,'44')' at line 1
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
求大神指导
String sql = "insert into flux values('11','22','"+time+"','44') ";
你的time没有用单引号引起来
String sql = "insert into flux values('11','22','"+time+"','44') ";
你的time没有用单引号引起来