org.hibernate.engine.jdbc.connections.internal.DriverManagerConnectionProviderImpl#configure ( )源码实例Demo

下面列出了org.hibernate.engine.jdbc.connections.internal.DriverManagerConnectionProviderImpl#configure ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

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;
}
 
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;
}
 
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);
}
 
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;
}