Example usage for java.sql SQLTimeoutException getMessage

List of usage examples for java.sql SQLTimeoutException getMessage

Introduction

In this page you can find the example usage for java.sql SQLTimeoutException getMessage.

Prototype

public String getMessage() 

Source Link

Document

Returns the detail message string of this throwable.

Usage

From source file:org.pentaho.reporting.engine.classic.extensions.datasources.pmd.SimplePmdDataFactory.java

private TableModel buildTableModel(final DatabaseMeta databaseMeta, final Query queryObject,
        final MappedQuery mappedQuery, final DataRow parameters) throws ReportDataFactoryException {

    initializeDataFactory(databaseMeta, parameters);

    final ReportParameterValues computedParameterSet = new ReportParameterValues();
    computedParameterSet.put(DataFactory.QUERY_LIMIT, parameters.get(DataFactory.QUERY_LIMIT));
    computedParameterSet.put(DataFactory.QUERY_TIMEOUT, parameters.get(DataFactory.QUERY_TIMEOUT));

    final String[] parameterNames = computeQueryParameter(queryObject, mappedQuery, parameters,
            computedParameterSet);/*from  w  ww  .j a v a  2 s  . c  o m*/

    // Add in model parameters if not overridden in report - PRD-3862

    // Check to see if timeout is already in the report
    computeQueryTimeout(queryObject, computedParameterSet);
    // Check to see if limit is already in the report
    computeQueryLimit(queryObject, computedParameterSet);
    // End PRD-3862 fix

    try {
        final String sqlQuery = mappedQuery.getQuery();
        final TableModel tableModel = sqlReportDataFactory.parametrizeAndQuery(computedParameterSet, sqlQuery,
                parameterNames);

        // now lets wrap up the model into a meta-data aware model ..
        final List<Selection> selections = queryObject.getSelections();
        if (selections.size() != tableModel.getColumnCount()) {
            throw new ReportDataFactoryException("Whatever the query returned, it does not look familiar");
        }
        // cast is safe, as the SQL-Datasource is guaranteed to return a
        // MetaTableModel
        return new PmdMetaTableModel((MetaTableModel) tableModel, queryObject.getSelections());
    } catch (final SQLTimeoutException e) {
        //it catch exception only for java 1.6 and jdbc 4
        throw new ReportDataFactoryQueryTimeoutException();
    } catch (final SQLException e) {
        //it catch other exception end timeout for jdbc3, so add message from jdbc driver to message
        throw new ReportDataFactoryException("SQL-query did not execute successfully. " + e.getMessage(), e);
    }

}