org.hibernate.engine.jdbc.connections.internal.DriverManagerConnectionProviderImpl Java Examples

The following examples show how to use org.hibernate.engine.jdbc.connections.internal.DriverManagerConnectionProviderImpl. 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: NoJdbcConnectionProviderInitiator.java    From hibernate-reactive with GNU Lesser General Public License v2.1 5 votes vote down vote up
@Override
public ConnectionProvider initiateService(Map configurationValues, ServiceRegistryImplementor registry) {
	ConnectionProvider provider = ConnectionProviderInitiator.INSTANCE.initiateService(configurationValues, registry);
	if (provider instanceof DriverManagerConnectionProviderImpl) {
		registry.getService( SchemaManagementTool.class )
				.setCustomDatabaseGenerationTarget( new ReactiveGenerationTarget(registry) );
		return NoJdbcConnectionProvider.INSTANCE;
	}
	return provider;
}
 
Example #2
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 #3
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 #4
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 #5
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;
}