<分区>
我正在尝试运行准备语句并在 MySQL 语法中遇到错误。不确定错误是什么?
代码:
PreparedStatement stmt = null;
conn = ds.getConnection();
String query = "select distinct FName from PRL p1, RequestView p2 where p1.RequestId = p2.RequestId and p1.PackageId = p2.PackageId and p1.ProductId = ? and p1.ProductNumber = ? and p1.Version = ? order by p2.ArtName";
stmt = conn.prepareStatement(query);
stmt.setString(1,id);
stmt.setString(2,num);
stmt.setString(3,ver);
rs = stmt.executeQuery(query);
错误:
Caused by: 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 '? and p1.ESTProductMatNumber =? and p1.Version =? order by p2.ArtworkName' at line 1
at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:936)