use of com.cubrid.jdbc.proxy.driver.CUBRIDStatementProxy in project cubrid-manager by CUBRID.
the class QueryEditorPart method runQueryPlanOnly.
/**
* Fetch execution plans while running SQLs
*
* @param queries String
*/
private void runQueryPlanOnly(Vector<String> qVector) {
try {
connection.getConnection(true);
} catch (SQLException e) {
CommonUITool.openErrorBox(e.getLocalizedMessage());
return;
}
if (!connection.hasConnection()) {
return;
}
// clearPlan();
CUBRIDStatementProxy statement = null;
int i = 0;
try {
int len = qVector.size();
for (i = 0; i < len; i++) {
String sql = qVector.get(i).toString();
statement = getStatement(connection.getConnection(), false);
StructQueryPlan sq = new StructQueryPlan(sql, statement.getQueryplan(sql), new Date());
if (combinedQueryComposite.getQueryPlanResultComp().isDisposed()) {
combinedQueryComposite.newQueryPlanComp();
}
combinedQueryComposite.getQueryPlanResultComp().makePlan(sq, i);
QueryUtil.freeQuery(statement);
statement = null;
if (collectExecStats) {
displayTuneModeResult(new TuneModeModel(sq, null));
}
}
} catch (Exception ee) {
int errorCode = 0;
if (SQLException.class.isInstance(ee)) {
errorCode = ((SQLException) ee).getErrorCode();
}
String errmsg = "";
if (isAutocommit) {
try {
queryAction(QUERY_ACTION.ROLLBACK);
} catch (SQLException e1) {
LOGGER.error("", e1);
}
}
SQLEditorComposite sqlEditorComp = combinedQueryComposite.getSqlEditorComp();
sqlEditorComp.txtFind((String) qVector.get(i), 0, false, false, true, false);
StyledText txaEdit = sqlEditorComp.getText();
int line = txaEdit.getLineAtOffset(txaEdit.getSelection().x) + 1;
String errorLineMsg = Messages.bind(Messages.errWhere, line);
errmsg += Messages.runError + errorCode + StringUtil.NEWLINE + errorLineMsg + StringUtil.NEWLINE + Messages.errorHead + ee.getMessage();
CTabFolder queryResultTabFolder = combinedQueryComposite.getQueryResultComp().getQueryResultTabFolder();
StyledText logMessagesArea = combinedQueryComposite.getQueryResultComp().getLogMessagesArea();
QueryResultComposite queryResult = combinedQueryComposite.getQueryResultComp();
queryResultTabFolder.setSelection(0);
String logMessage = logMessagesArea.getText();
if (logMessage != null && logMessage.length() > 0) {
logMessage += StringUtil.NEWLINE;
}
logMessagesArea.setText(logMessage + StringUtil.NEWLINE + errmsg);
logMessagesArea.setTopIndex(logMessagesArea.getLineCount() - 1);
queryResult.setSelection();
LOGGER.error(ee.getMessage(), ee);
} finally {
QueryUtil.freeQuery(statement);
statement = null;
}
autoCommitItem.setEnabled(true);
queryPlanItem.setEnabled(true);
setPstmtParaItem.setEnabled(true);
isRunning = false;
}
use of com.cubrid.jdbc.proxy.driver.CUBRIDStatementProxy in project cubrid-manager by CUBRID.
the class EditQueryPlanDialog method checkQuery.
/**
* check the query
*
* @param queries String
* @return error message String
*/
private String checkQuery(String queries) {
if (queries.trim().length() == 0) {
return Messages.errQueryplanStmtEmpty;
}
Vector<String> qVector = QueryUtil.queriesToQuery(queries);
CUBRIDStatementProxy statement = null;
Connection queryConn = null;
try {
queryConn = getConnection();
statement = (CUBRIDStatementProxy) queryConn.createStatement();
int len = qVector.size();
for (int i = 0; i < len; i++) {
String sql = qVector.get(i);
statement.getQueryplan(sql);
}
} catch (SQLException e) {
return e.getMessage();
} finally {
QueryUtil.freeQuery(queryConn, statement);
}
return null;
}
Aggregations