报错信息:com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException:YouhaveanerrorinyourSQLsyntax;checkthemanualthatcorrespondstoyourMySQLserverversionfortherightsyntaxto...
报错信息: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 'create')' at line 1
方法:
public void create(String fname,String opath,String npath,String type ) throws SQLException {
Connection conn = null;
Statement st = null;
ResultSet rs = null;
try {
conn = JdbcUtils.getConnection();
st = conn.createStatement();
String sql = "insert into Logs(fname,oldpath, newpath, opdate, optype) values('"
+fname+"', '"+ opath+"', '"+npath+"', "+" NOW()"+", '"+type+"')";
int SQL = st.executeUpdate(sql);
System.out.println(sql);
} finally {
JdbcUtils.free(rs, st, conn);
}
}
打印出的sql语句:insert into Logs(fname,oldpath, newpath, opdate, optype) values('test', 'oldpath', 'newpath', NOW(), '新建文件')
已解决。
展开