【发布时间】:2012-06-08 09:13:06
【问题描述】:
我有这个查询,在我的 sql 命令行客户端中执行时可以正常执行并在两个表中获取条目,但执行它会出错。
com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: 你的 SQL 语法有错误;检查男人 ual 对应于您的 MySQL 服务器版本,以便在 'INSERT INTO tm_belonging(B ID,BELONGING_TYPE,BELONGING_TEXT)VALUES(LAST_INSERT_ID' 在第 1 行
String sql="INSERT INTO tm_visitor(VISITOR_TEXT,COMPANY_TEXT,CONTACT,PERSON_TO_MEET,DEPARTMENT_TEXT,FLOOR)Values(?,?,?,?,?,?);"+"INSERT INTO tm_belonging(BID,BELONGING_TYPE,BELONGING_TEXT)VALUES(LAST_INSERT_ID(),?,?);";
PreparedStatement pst = conn.prepareStatement(sql);
pst.setString(1,VisitorName.toUpperCase());
pst.setString(2,Company.toUpperCase());
pst.setString(3,Contact);
pst.setString(4,WhomeToMeet.toUpperCase());
pst.setString(5,Department);
pst.setString(6,DepartmentFloor);
pst.setString(7,BType);
pst.setString(8,Belonging);
pst.executeUpdate();
pst.close();
【问题讨论】: