Java Code Examples for org.hibernate.engine.jdbc.connections.internal.DriverManagerConnectionProviderImpl#configure()

The following examples show how to use org.hibernate.engine.jdbc.connections.internal.DriverManagerConnectionProviderImpl#configure() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: SimpleMultiTenantConnectionProvider.java    From HibernateDemos with The Unlicense 5 votes vote down vote up
private ConnectionProvider buildConnectionProvider(String dbName) {
	Properties props = new Properties( null );
	props.put( "hibernate.connection.driver_class", DRIVER );
	// Inject dbName into connection url string.
	props.put( "hibernate.connection.url", String.format( URL, dbName ) );
	props.put( "hibernate.connection.username", USER );
	props.put( "hibernate.connection.password", PASS );
	
	// Note that DriverManagerConnectionProviderImpl is an internal class.  However, rather than creating
	// a ConnectionProvider, I'm using it for simplicity's sake.
	// DriverManagerConnectionProviderImpl obtains a Connection through the JDBC Driver#connect
	DriverManagerConnectionProviderImpl connectionProvider = new DriverManagerConnectionProviderImpl();
	connectionProvider.configure( props );
	return connectionProvider;
}
 
Example 2
Source File: SimpleMultiTenantConnectionProvider.java    From hibernate-demos with Apache License 2.0 5 votes vote down vote up
private ConnectionProvider buildConnectionProvider(String dbName) {
	Properties props = new Properties( null );
	props.put( "hibernate.connection.driver_class", DRIVER );
	// Inject dbName into connection url string.
	props.put( "hibernate.connection.url", String.format( URL, dbName ) );
	props.put( "hibernate.connection.username", USER );
	props.put( "hibernate.connection.password", PASS );
	
	// Note that DriverManagerConnectionProviderImpl is an internal class.  However, rather than creating
	// a ConnectionProvider, I'm using it for simplicity's sake.
	// DriverManagerConnectionProviderImpl obtains a Connection through the JDBC Driver#connect
	DriverManagerConnectionProviderImpl connectionProvider = new DriverManagerConnectionProviderImpl();
	connectionProvider.configure( props );
	return connectionProvider;
}
 
Example 3
Source File: MapMultiTenantConnectionProvider.java    From tutorials with MIT License 5 votes vote down vote up
private void initConnectionProviderForTenant(String tenantId) throws IOException {
    Properties properties = new Properties();
    properties.load(getClass().getResourceAsStream(String.format("/hibernate-database-%s.properties", tenantId)));
    DriverManagerConnectionProviderImpl connectionProvider = new DriverManagerConnectionProviderImpl();
    connectionProvider.configure(properties);
    this.connectionProviderMap.put(tenantId, connectionProvider);
}
 
Example 4
Source File: SchemaMultiTenantConnectionProvider.java    From tutorials with MIT License 5 votes vote down vote up
private ConnectionProvider initConnectionProvider() throws IOException {
    Properties properties = new Properties();
    properties.load(getClass().getResourceAsStream("/hibernate-schema-multitenancy.properties"));

    DriverManagerConnectionProviderImpl connectionProvider = new DriverManagerConnectionProviderImpl();
    connectionProvider.configure(properties);
    return connectionProvider;
}