@Before public void before() throws DatabaseDialectException { when( dialectService.getDialect( connection ) ).thenReturn( driverLocatorDialect ); when( connection.getDatabaseType() ).thenReturn( databaseType ); when( connection.getDatabaseType().getShortName() ).thenReturn( "SomeDBType" ); when( driverLocatorDialect.getNativeDriver() ).thenReturn( nativeDriverName ); when( driverLocatorDialect.getURLWithExtraOptions( connection ) ).thenReturn( jdbcUrl ); when( plainDialect.getNativeDriver() ).thenReturn( nativeDriverName ); when( plainDialect.getURLWithExtraOptions( connection ) ).thenReturn( jdbcUrl ); }
IDatabaseDialect dialect = dialectService.getDialect( connection ); conn = DriverManager.getConnection( dialect.getURLWithExtraOptions( connection ), connection.getUsername(), connection.getPassword() ); return conn;
public static SQLConnection getConnection( String connectionName ) throws DatasourceServiceException { IDatabaseConnection connection = null; try { ConnectionServiceImpl service = new ConnectionServiceImpl(); connection = service.getConnectionByName( connectionName ); DatabaseDialectService dialectService = new DatabaseDialectService(); IDatabaseDialect dialect = dialectService.getDialect( connection ); String driverClass = null; if ( connection.getDatabaseType().getShortName().equals( "GENERIC" ) ) { driverClass = connection.getAttributes().get( GenericDatabaseDialect.ATTRIBUTE_CUSTOM_DRIVER_CLASS ); } else { driverClass = dialect.getNativeDriver(); } return new SQLConnection( driverClass, dialect.getURLWithExtraOptions( connection ), connection.getUsername(), connection.getPassword(), null ); } catch ( ConnectionServiceException e1 ) { return null; } catch ( DatabaseDialectException e ) { return null; } }
url = dialect.getURLWithExtraOptions( databaseConnection ); } catch ( DatabaseDialectException e ) { url = null;
conn = DriverManager.getConnection( dialect.getURLWithExtraOptions( connection ), connection.getUsername(), connection.getPassword() ); return conn;
basicDatasource.setUrl( dialect.getURLWithExtraOptions( databaseConnection ) ); } catch ( DatabaseDialectException e ) { basicDatasource.setUrl( null );
} else { pentahoConnection = PentahoConnectionFactory.getConnection( IPentahoConnection.SQL_DATASOURCE, driverClass, dialect.getURLWithExtraOptions( connection ), connection.getUsername(), getConnectionPassword( connection.getName(), connection.getPassword() ), null, this );