Tabnine Logo
DriverManagerConnectionProviderImpl
Code IndexAdd Tabnine to your IDE (free)

How to use
DriverManagerConnectionProviderImpl
in
org.hibernate.engine.jdbc.connections.internal

Best Java code snippets using org.hibernate.engine.jdbc.connections.internal.DriverManagerConnectionProviderImpl (Showing top 20 results out of 315)

origin: hibernate/hibernate-orm

protected void registerConnectionProvider(String tenantIdentifier) {
  Properties properties = properties();
  properties.put( Environment.URL,
    tenantUrl(properties.getProperty( Environment.URL ), tenantIdentifier) );
  DriverManagerConnectionProviderImpl connectionProvider =
    new DriverManagerConnectionProviderImpl();
  connectionProvider.configure( properties );
  connectionProviderMap.put( tenantIdentifier, connectionProvider );
}
//end::multitenacy-hibernate-MultiTenantConnectionProvider-example[]
origin: hibernate/hibernate-orm

@Override
public void stop() {
  delegate.stop();
}
origin: hibernate/hibernate-orm

@Override
public void configure(Map configurationValues) {
  log.usingHibernateBuiltInConnectionPool();
  PooledConnections pool = buildPool( configurationValues, serviceRegistry );
  final long validationInterval = ConfigurationHelper.getLong( VALIDATION_INTERVAL, configurationValues, 30 );
  PoolState newstate = new PoolState( pool, validationInterval );
  this.state = newstate;
}
origin: hibernate/hibernate-orm

@Override
public void buildEntityManagerFactory() {
  connectionProvider = new DriverManagerConnectionProviderImpl();
  connectionProvider.configure( Environment.getProperties() );
  try(Connection connection = connectionProvider.getConnection();
    Statement statement = connection.createStatement()) {
    statement.execute( "DROP TABLE IF EXISTS roles CASCADE" );
    statement.execute( "CREATE TABLE roles ( id BIGINT NOT NULL PRIMARY KEY GENERATED BY DEFAULT AS IDENTITY )" );
  }
  catch (SQLException e) {
    fail(e.getMessage());
  }
  super.buildEntityManagerFactory();
}
origin: hibernate/hibernate-orm

    new DriverManagerConnectionProviderImpl();
connectionProvider.configure( properties() );
  new SchemaDropperImpl( serviceRegistry ).doDrop( metadata, false, schemaGenerator );
  serviceRegistry.destroy();
  connectionProvider.stop();
origin: stackoverflow.com

connectionProvider = new DriverManagerConnectionProviderImpl();
origin: hibernate/hibernate-orm

private static DriverManagerConnectionProviderImpl buildConnectionProvider(Properties props, final boolean allowAggressiveRelease) {
  DriverManagerConnectionProviderImpl connectionProvider = new DriverManagerConnectionProviderImpl() {
    public boolean supportsAggressiveRelease() {
      return allowAggressiveRelease;
    }
  };
  connectionProvider.configure( props );
  return connectionProvider;
}
origin: hibernate/hibernate-orm

@Override
public void releaseResources() {
  super.releaseResources();
  try(Connection connection = connectionProvider.getConnection();
    Statement statement = connection.createStatement()) {
    statement.execute( "DROP TABLE IF EXISTS roles CASCADE" );
  }
  catch (SQLException e) {
    fail(e.getMessage());
  }
  if ( connectionProvider != null ) {
    connectionProvider.stop();
  }
}
origin: hibernate/hibernate-orm

@Override
public void closeConnection(Connection conn) throws SQLException {
  if ( conn == null ) {
    return;
  }
  if ( nonEnlistedConnections.contains( conn ) ) {
    nonEnlistedConnections.remove( conn );
    delegate.closeConnection( conn );
  }
  else {
    // do nothing.  part of the enlistment contract here is that the XAResource wrapper
    // takes that responsibility.
  }
}
origin: hibernate/hibernate-orm

@Override
public Connection getConnection() throws SQLException {
  openConnection++;
  return super.getConnection();
}
origin: hibernate/hibernate-orm

private PooledConnections buildPool(Map configurationValues, ServiceRegistryImplementor serviceRegistry) {
  final boolean autoCommit = ConfigurationHelper.getBoolean(
      AvailableSettings.AUTOCOMMIT,
      configurationValues,
      false
  );
  final int minSize = ConfigurationHelper.getInt( MIN_SIZE, configurationValues, 1 );
  final int maxSize = ConfigurationHelper.getInt( AvailableSettings.POOL_SIZE, configurationValues, 20 );
  final int initialSize = ConfigurationHelper.getInt( INITIAL_SIZE, configurationValues, minSize );
  ConnectionCreator connectionCreator = buildCreator( configurationValues, serviceRegistry );
  PooledConnections.Builder pooledConnectionBuilder = new PooledConnections.Builder(
      connectionCreator,
      autoCommit
  );
  pooledConnectionBuilder.initialSize( initialSize );
  pooledConnectionBuilder.minSize( minSize );
  pooledConnectionBuilder.maxSize( maxSize );
  return pooledConnectionBuilder.build();
}
origin: hibernate/hibernate-orm

connectionCreatorBuilder.setDriver( loadDriverIfPossible( driverClassName, serviceRegistry ) );
origin: hibernate/hibernate-orm

@Before
public void setUp() throws Exception {
  connectionProvider =
      new DriverManagerConnectionProviderImpl();
  connectionProvider.configure( properties() );
  connection = connectionProvider.getConnection();
  ssr = new StandardServiceRegistryBuilder()
    .applySetting( AvailableSettings.HBM2DDL_CONNECTION, connection )
    .build();
  tool = (HibernateSchemaManagementTool) ssr.getService( SchemaManagementTool.class );
  configurationValues = ssr.getService( ConfigurationService.class ).getSettings();
  executionOptions = new ExecutionOptions() {
    @Override
    public boolean shouldManageNamespaces() {
      return true;
    }
    @Override
    public Map getConfigurationValues() {
      return configurationValues;
    }
    @Override
    public ExceptionHandler getExceptionHandler() {
      return ExceptionHandlerLoggedImpl.INSTANCE;
    }
  };
}
origin: hibernate/hibernate-orm

connectionProvider = new DriverManagerConnectionProviderImpl();
origin: hibernate/hibernate-orm

@Override
public void closeConnection(Connection conn) throws SQLException {
  super.closeConnection( conn );
  openConnection--;
}
origin: hibernate/hibernate-orm

@Override
public Connection getConnection() throws SQLException {
  Transaction currentTransaction = findCurrentTransaction();
  try {
    if ( currentTransaction == null ) {
      // this block handles non enlisted connections ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      Connection connection = delegate.getConnection();
      nonEnlistedConnections.add( connection );
      return connection;
    }
    // this portion handles enlisted connections ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    Connection connection = (Connection) TestingJtaPlatformImpl.synchronizationRegistry().getResource(
        CONNECTION_KEY
    );
    if ( connection == null ) {
      connection = delegate.getConnection();
      TestingJtaPlatformImpl.synchronizationRegistry().putResource( CONNECTION_KEY, connection );
      XAResourceWrapper xaResourceWrapper = new XAResourceWrapper( this, connection );
      currentTransaction.enlistResource( xaResourceWrapper );
    }
    return connection;
  }
  catch (SQLException e) {
    throw e;
  }
  catch (Exception e) {
    throw new SQLException(e);
  }
}
origin: org.hibernate.orm/hibernate-core

private PooledConnections buildPool(Map configurationValues, ServiceRegistryImplementor serviceRegistry) {
  final boolean autoCommit = ConfigurationHelper.getBoolean(
      AvailableSettings.AUTOCOMMIT,
      configurationValues,
      false
  );
  final int minSize = ConfigurationHelper.getInt( MIN_SIZE, configurationValues, 1 );
  final int maxSize = ConfigurationHelper.getInt( AvailableSettings.POOL_SIZE, configurationValues, 20 );
  final int initialSize = ConfigurationHelper.getInt( INITIAL_SIZE, configurationValues, minSize );
  ConnectionCreator connectionCreator = buildCreator( configurationValues, serviceRegistry );
  PooledConnections.Builder pooledConnectionBuilder = new PooledConnections.Builder(
      connectionCreator,
      autoCommit
  );
  pooledConnectionBuilder.initialSize( initialSize );
  pooledConnectionBuilder.minSize( minSize );
  pooledConnectionBuilder.maxSize( maxSize );
  return pooledConnectionBuilder.build();
}
origin: org.hibernate.orm/hibernate-core

connectionCreatorBuilder.setDriver( loadDriverIfPossible( driverClassName, serviceRegistry ) );
origin: hibernate/hibernate-orm

protected void registerConnectionProvider(String tenantIdentifier, TimeZone timeZone) {
  Properties properties = properties();
  properties.put(
    Environment.URL,
    tenantUrl( properties.getProperty( Environment.URL ), tenantIdentifier )
  );
  DriverManagerConnectionProviderImpl connectionProvider =
      new DriverManagerConnectionProviderImpl();
  connectionProvider.configure( properties );
  connectionProviderMap.put( tenantIdentifier, connectionProvider );
  timeZoneTenantMap.put( tenantIdentifier, timeZone );
}
//end::multitenacy-hibernate-timezone-configuration-registerConnectionProvider-example[]
origin: org.hibernate.orm/hibernate-core

connectionProvider = new DriverManagerConnectionProviderImpl();
org.hibernate.engine.jdbc.connections.internalDriverManagerConnectionProviderImpl

Javadoc

A connection provider that uses the java.sql.DriverManager directly to open connections and provides a very rudimentary connection pool.

IMPL NOTE : not intended for production use!

Thanks to Oleg Varaksin and his article on object pooling using the java.util.concurrent package, from which much of the pooling code here is derived. See http://ovaraksin.blogspot.com/2013/08/simple-and-lightweight-pool.html

Most used methods

  • <init>
  • configure
  • stop
  • buildCreator
  • buildPool
  • closeConnection
  • getConnection
  • loadDriverIfPossible
  • isUnwrappableAs
  • unwrap

Popular in Java

  • Start an intent from android
  • notifyDataSetChanged (ArrayAdapter)
  • setScale (BigDecimal)
  • getSupportFragmentManager (FragmentActivity)
  • URL (java.net)
    A Uniform Resource Locator that identifies the location of an Internet resource as specified by RFC
  • URLConnection (java.net)
    A connection to a URL for reading or writing. For HTTP connections, see HttpURLConnection for docume
  • Charset (java.nio.charset)
    A charset is a named mapping between Unicode characters and byte sequences. Every Charset can decode
  • Calendar (java.util)
    Calendar is an abstract base class for converting between a Date object and a set of integer fields
  • Executor (java.util.concurrent)
    An object that executes submitted Runnable tasks. This interface provides a way of decoupling task s
  • IsNull (org.hamcrest.core)
    Is the value null?
  • Top plugins for Android Studio
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now