protected void initWithJNDI( final String jndiName ) {
// bump();
// myCtr = connectionCtr;
try {
IDBDatasourceService datasourceService = PentahoSystem.getObjectFactory().get( IDBDatasourceService.class, null );
DataSource dataSource = datasourceService.getDataSource( jndiName );
if ( dataSource != null ) {
nativeConnection = captureConnection( dataSource.getConnection() );
if ( nativeConnection == null ) {
logger.error( Messages.getInstance()
.getErrorString( "ConnectFactory.ERROR_0001_INVALID_CONNECTION", jndiName ) ); //$NON-NLS-1$
// clear datasource cache
datasourceService.clearDataSource( jndiName );
} else {
enhanceConnection( nativeConnection );
}
} else {
logger
.error( Messages.getInstance().getErrorString( "ConnectFactory.ERROR_0001_INVALID_CONNECTION",
jndiName ) ); //$NON-NLS-1$
// clear datasource cache
datasourceService.clearDataSource( jndiName );
}
} catch ( Exception e ) {
logger.error(
Messages.getInstance().getErrorString( "ConnectFactory.ERROR_0001_INVALID_CONNECTION", jndiName ), e ); //$NON-NLS-1$
close(); // do not allow connection to be used as it might not be enhanced
// clear datasource cache
try {
IDBDatasourceService datasourceService =
PentahoSystem.getObjectFactory().get( IDBDatasourceService.class, null );
datasourceService.clearDataSource( jndiName );
} catch ( ObjectFactoryException objface ) {
logger.error( Messages.getInstance().getErrorString(
"ConnectFactory.ERROR_0002_UNABLE_TO_FACTORY_OBJECT=Unable to factory object", jndiName ), e ); //$NON-NLS-1$
}
}