Can JDBC statement run explain plan on query string?
The code throws SQL exception Error message: Incorrect syntax near the keyword 'plan'. Stacktrace is null
I just copy from internet of using stmt.execute. However, it seems that stmt.execute() only Returns true if the first result is a ResultSet object; false if it is an update count or there are no results
conn = getEntityManager().unwrap(java.sql.Connection.class);
stmt = conn.createStatement();
stmt.execute("explain plan for SELECT 1 from Dual"); // throws sql exception
rs = stmt.executeQuery("select plan_table_output from table(dbms_xplan.display())");
while (rs.next())
{
System.out.println(rs.getString(1));
}