我尝试运行此 mysql 查询,但出现此错误:
com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException:您的 SQL 语法有错误;检查与您的 MySQL 服务器版本相对应的手册,以在 'SET @r2 = GeomFromText('Polygon((1 1,5 1,5 5,1 5,1 1))'); 附近使用正确的语法;在第 2 行选择 MBROVERLAPS(@r1'
代码:
public String getoverlap(Rectangle recA, Rectangle recB){
String result = "-1";
String query;
query =
"SET @r1 = GeomFromText(\'Polygon((1 1, 5 1,5 5,1 5,1 1))\');\n" +
"SET @r2 = GeomFromText(\'Polygon((1 1,5 1,5 5,1 5,1 1))\');\n" +
"select MBROVERLAPS(@r1,@r2);" ;
System.out.println("query--:\n "+query);
try {
this.statement = this.connection.createStatement();
ResultSet rs = this.statement.executeQuery(query);
System.out.println("kkk:" +rs.toString());
if(rs!=null){
result = rs.getString("MBROVERLAPS(@r1,@r2)");
}
else{
System.out.println("Debug: lathos sthn getoverlap");
}
statement.close();
} catch (SQLException ex) {
System.out.println("debug: sqlEcxeption");
Logger.getLogger(Database.class.getName()).log(Level.SEVERE, null, ex);
}
return result;
}
哪里有问题?