Search in sources :

Example 1 with Sql

use of com.yahoo.dba.perf.myperf.common.Sql in project mysql_perf_analyzer by yahoo.

the class TableMetaProcessor method queryMultiple.

@Override
public void queryMultiple(MyPerfContext context, DBInstanceInfo dbinfo, String appUser, DBConnectionWrapper connWrapper, QueryParameters qps, Map<String, ResultList> rListMap) throws java.sql.SQLException {
    for (int i = 0; i < TBL_QUERIES.length; i++) {
        QueryParameters qps2 = new QueryParameters();
        qps2.setSql(TBL_QUERIES[i]);
        qps2.getSqlParams().put("p_1", qps.getSqlParams().get("p_1"));
        qps2.getSqlParams().put("p_2", qps.getSqlParams().get("p_2"));
        ResultList rList = null;
        try {
            rList = context.getQueryEngine().executeQueryGeneric(qps2, connWrapper, qps.getMaxRows());
        } catch (Throwable th) {
            logger.log(Level.WARNING, "Error when retrieve meta data", th);
            if (th instanceof SQLException) {
                //check if the connection is still good
                if (!DBUtils.checkConnection(connWrapper.getConnection())) {
                    throw SQLException.class.cast(th);
                }
            }
            Sql sql = context.getSqlManager().getSql(qps2.getSql());
            if (sql != null && sql.isErrorInline()) {
                rList = new ResultList();
                ColumnDescriptor desc = new ColumnDescriptor();
                desc.addColumn("Status", false, 0);
                desc.addColumn("Message", false, 1);
                rList.setColumnDescriptor(desc);
                ResultRow row = new ResultRow();
                row.setColumnDescriptor(desc);
                row.addColumn("Error");
                row.addColumn(th.getMessage());
                rList.addRow(row);
            }
        }
        rListMap.put(TBL_QUERIES[i], rList);
    }
}
Also used : ResultRow(com.yahoo.dba.perf.myperf.common.ResultRow) ResultList(com.yahoo.dba.perf.myperf.common.ResultList) SQLException(java.sql.SQLException) ColumnDescriptor(com.yahoo.dba.perf.myperf.common.ColumnDescriptor) QueryParameters(com.yahoo.dba.perf.myperf.common.QueryParameters) Sql(com.yahoo.dba.perf.myperf.common.Sql)

Aggregations

ColumnDescriptor (com.yahoo.dba.perf.myperf.common.ColumnDescriptor)1 QueryParameters (com.yahoo.dba.perf.myperf.common.QueryParameters)1 ResultList (com.yahoo.dba.perf.myperf.common.ResultList)1 ResultRow (com.yahoo.dba.perf.myperf.common.ResultRow)1 Sql (com.yahoo.dba.perf.myperf.common.Sql)1 SQLException (java.sql.SQLException)1