Search in sources :

Example 21 with DBDatasourceServiceException

use of org.pentaho.platform.api.data.DBDatasourceServiceException in project pentaho-platform by pentaho.

the class PlatformKettleDataSourceProvider method getNamedDataSourceFromService.

protected <T extends IDBDatasourceService> DataSource getNamedDataSourceFromService(Class<T> dataSourceServiceInterface, String dataSourceName) throws DataSourceNamingException {
    T datasourceService = PentahoSystem.get(dataSourceServiceInterface, null);
    IDBDatasourceService service = (datasourceService == null) ? PentahoSystem.get(IDBDatasourceService.class, null) : datasourceService;
    if (service != null) {
        try {
            return service.getDataSource(dataSourceName);
        } catch (DBDatasourceServiceException ex) {
            throw new DataSourceNamingException(ex);
        }
    }
    return null;
}
Also used : DBDatasourceServiceException(org.pentaho.platform.api.data.DBDatasourceServiceException) DataSourceNamingException(org.pentaho.di.core.database.DataSourceNamingException) IDBDatasourceService(org.pentaho.platform.api.data.IDBDatasourceService)

Example 22 with DBDatasourceServiceException

use of org.pentaho.platform.api.data.DBDatasourceServiceException in project data-access by pentaho.

the class AgileHelper method getDialect.

public static String getDialect(DatabaseMeta meta, String jndiName) {
    String dialect = null;
    try {
        Connection conn = getConnection(jndiName);
        dialect = conn.getMetaData().getDatabaseProductName();
        if (dialect.indexOf("HSQL") >= 0) {
            dialect = "Hypersonic";
        } else if (dialect.indexOf("Microsoft SQL") >= 0) {
            // Hack-around for BACKLOG-845
            dialect = "MSSQLNATIVE";
        }
        conn.close();
    } catch (SQLException e) {
        logger.debug("Error determining database type from connection", e);
    } catch (DBDatasourceServiceException e) {
        logger.debug("Error determining database type from connection - getting JNDI connection", e);
    }
    return dialect;
}
Also used : DBDatasourceServiceException(org.pentaho.platform.api.data.DBDatasourceServiceException) SQLException(java.sql.SQLException) Connection(java.sql.Connection)

Aggregations

DBDatasourceServiceException (org.pentaho.platform.api.data.DBDatasourceServiceException)22 IDatabaseConnection (org.pentaho.database.model.IDatabaseConnection)11 DataSource (javax.sql.DataSource)9 Test (org.junit.Test)7 IDatabaseDialectService (org.pentaho.database.service.IDatabaseDialectService)6 HashMap (java.util.HashMap)5 Matchers.containsString (org.hamcrest.Matchers.containsString)5 DatabaseConnection (org.pentaho.database.model.DatabaseConnection)5 DatabaseDialectService (org.pentaho.database.service.DatabaseDialectService)5 IDBDatasourceService (org.pentaho.platform.api.data.IDBDatasourceService)5 DatasourceMgmtServiceException (org.pentaho.platform.api.repository.datasource.DatasourceMgmtServiceException)5 IDatasourceMgmtService (org.pentaho.platform.api.repository.datasource.IDatasourceMgmtService)5 NamingException (javax.naming.NamingException)3 Before (org.junit.Before)3 DatabaseTypeHelper (org.pentaho.database.util.DatabaseTypeHelper)3 ObjectFactoryException (org.pentaho.platform.api.engine.ObjectFactoryException)3 SQLException (java.sql.SQLException)2 Properties (java.util.Properties)2 InitialContext (javax.naming.InitialContext)2 PoolingDataSource (org.apache.commons.dbcp.PoolingDataSource)2