Can JDBC statement run execution plan / explain plan?

戏子无情 提交于 2019-12-01 13:02:35

问题


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));
}

来源:https://stackoverflow.com/questions/58319845/can-jdbc-statement-run-execution-plan-explain-plan

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!