java - Retrieve query execution plan text from a MSSQL server using JDBC -


i have following java method returning statement itself. how can retrieve mssql query execution plan text using jdbc?

 public string explainstatementmssql(string sqlstatement) {     connection connection = null;     statement statement = null;     resultset rs = null;     stringbuilder output = new stringbuilder();     try {       connection = utilities.getconnection();       connection.setautocommit(false);       statement = connection.createstatement();       statement.execute("set showplan_text on");       statement.executequery(sqlstatement);       rs = statement.getresultset();       while (rs.next()) {         output.append(rs.getstring(1)).append("\n");       }       statement.execute("set showplan_text off");       connection.commit();     }     catch (exception e) {       e.printstacktrace();     }     {       utilities.close(rs, statement, connection);     }     return output.tostring();   } 

environment: java -version

java version "1.7.0_101" openjdk runtime environment (icedtea 2.6.6) (7u101-2.6.6-0ubuntu0.14.04.1) openjdk 64-bit server vm (build 24.95-b01, mixed mode) jtds-1.2.6.jar microsoft sql server 2012 

have had @ first example in following post: get query plan using jdbc preparedstatement on sql server

it's not using jtds, i'm sure minor tweaks should provide you're looking for.


Comments

Popular posts from this blog

javascript - Slick Slider width recalculation -

jsf - PrimeFaces Datatable - What is f:facet actually doing? -

angular2 services - Angular 2 RC 4 Http post not firing -