com.mysql.jdbc.exceptions.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 'position(orgI,orgII,orgIII,empStyle,positionType,positionName,empNum,  endDate,r' at line 1
求大神指导错在哪里了 数据库连接语句如下:
         private Connection conn;
private Statement stat;
private PreparedStatement ps;
private ResultSet rs;
private String url = "jdbc:mysql://localhost:3306/test?useUnicode=true&characterEncoding=GBK";
private String dbUser = "root";
private String dbPassword = ""; public void crePosition(String orgI, String orgII, String orgIII,
String empStyle, String positionType, String positionName,
String empNum, String endDate, String register, String regDate,
String changer, String chgDate, String positionDescription,
String empRequest) {
String sql = "insert into position(orgI,orgII,orgIII,empStyle,positionType,positionName,empNum,  endDate,register,regDate,changer, chgDate, positionDescription,empRequest) values(?,?,?,?,?,?,?,?,?,?,?,?,?,?) ";
try { DriverManager.registerDriver(new com.mysql.jdbc.Driver());// 驱动注册1
conn = DriverManager.getConnection(url,dbUser,dbPassword);// 获取可用的连接

ps=conn.prepareStatement(sql);;// 发送sql语句,执行查询


ps.setString(1, orgI);
ps.setString(2, orgII);
ps.setString(3, orgIII);
ps.setString(4, empStyle);
ps.setString(5, positionType);
ps.setString(6, positionName);
ps.setString(7, empNum);
ps.setString(8, endDate);
ps.setString(9, register);
ps.setString(10, regDate);
ps.setString(11, changer);
ps.setString(12, chgDate);
ps.setString(13, positionDescription);
ps.setString(14, empRequest);
ps.executeUpdate();
conn.close();
ps.close();
} catch (Exception e) {
e.printStackTrace();
}
return;
}

解决方案 »

  1.   

    insert into `position` (orgI,orgII,orgIII,empStyle,positionType,positionName,empNum, endDate,register,regDate,changer, chgDate, positionDescription,empRequest) values(?,?,?,?,?,?,?,?,?,?,?,?,?,?) 
      

  2.   

    你将表名、字段名加``试试
    insert into `position` (`orgI`,`orgII`,`orgIII`,`empStyle`,`positionType`,`positionName`,`empNum`, `endDate`,`register`,`regDate`,`changer`, `chgDate`, `positionDescription`,`empRequest`) values(?,?,?,?,?,?,?,?,?,?,?,?,?,?)
      

  3.   

    打印出来 在sql命令行试试