0
我嘗試運行此MySQL查詢和我有這個錯誤的java:MySQL查詢與MBROVERLAP
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 'SET @r2 = GeomFromText('Polygon((1 1,5 1,5 5,1 5,1 1))'); select MBROVERLAPS(@r1' at line 2
代碼:
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;
}
問題出在哪裏?