Package org.hibernate.service.jdbc.connections.spi

Examples of org.hibernate.service.jdbc.connections.spi.ConnectionProvider


      // nothing to do, but given the separate hierarchies have to handle this here.
    }

    final ClassLoaderService classLoaderService = registry.getService( ClassLoaderService.class );

    ConnectionProvider connectionProvider = null;
    String providerClassName = getConfiguredConnectionProviderName( configurationValues );
    if ( providerClassName != null ) {
      connectionProvider = instantiateExplicitConnectionProvider( providerClassName, classLoaderService );
    }
    else if ( configurationValues.get( Environment.DATASOURCE ) != null ) {
      connectionProvider = new DatasourceConnectionProviderImpl();
    }

    if ( connectionProvider == null ) {
      if ( c3p0ConfigDefined( configurationValues ) && c3p0ProviderPresent( classLoaderService ) ) {
        connectionProvider = instantiateExplicitConnectionProvider( C3P0_PROVIDER_CLASS_NAME,
            classLoaderService
        );
      }
    }

    if ( connectionProvider == null ) {
      if ( proxoolConfigDefined( configurationValues ) && proxoolProviderPresent( classLoaderService ) ) {
        connectionProvider = instantiateExplicitConnectionProvider( PROXOOL_PROVIDER_CLASS_NAME,
            classLoaderService
        );
      }
    }

    if ( connectionProvider == null ) {
      if ( configurationValues.get( Environment.URL ) != null ) {
        connectionProvider = new DriverManagerConnectionProviderImpl();
      }
    }

    if ( connectionProvider == null ) {
            LOG.noAppropriateConnectionProvider();
      connectionProvider = new UserSuppliedConnectionProviderImpl();
    }


    final Map injectionData = (Map) configurationValues.get( INJECTION_DATA );
    if ( injectionData != null && injectionData.size() > 0 ) {
      final ConnectionProvider theConnectionProvider = connectionProvider;
      new BeanInfoHelper( connectionProvider.getClass() ).applyToBeanInfo(
          connectionProvider,
          new BeanInfoHelper.BeanInfoDelegate() {
            public void processBeanInfo(BeanInfo beanInfo) throws Exception {
              PropertyDescriptor[] descritors = beanInfo.getPropertyDescriptors();
View Full Code Here


        Connection connection = null;
        try {
            fileWriter = new BufferedWriter(new FileWriter(getExistingDataFile()), IO_BUFFER_SIZE);
            Session session = (Session) entityManager.getDelegate();
            SessionFactoryImplementor sfi = (SessionFactoryImplementor) session.getSessionFactory();
            ConnectionProvider cp = sfi.getConnectionProvider();
            connection = cp.getConnection();
            CopyManager copyManager = new CopyManager((BaseConnection) connection);

            if (maxResults > 0) {
                copyManager.copyOut("COPY (" + selectNativeQuery + " LIMIT " + maxResults
                    + ") TO STDOUT WITH DELIMITER '" + DELIMITER + "'", fileWriter);
View Full Code Here

        ResultSet resultSet = null;
        try {
            fileWriter = new BufferedWriter(new FileWriter(getExistingDataFile()), IO_BUFFER_SIZE);
            Session session = (Session) this.entityManager.getDelegate();
            SessionFactoryImplementor sfi = (SessionFactoryImplementor) session.getSessionFactory();
            ConnectionProvider cp = sfi.getConnectionProvider();
            connection = cp.getConnection();
            statement = connection.prepareStatement(this.selectNativeQuery);
            resultSet = statement.executeQuery();
            int columnCount = resultSet.getMetaData().getColumnCount();
            while (resultSet.next()) {
                for (int i = 1; i < columnCount + 1; i++) {
View Full Code Here

   * @return the DataSource, or <code>null</code> if none found
   * @see org.hibernate.engine.spi.SessionFactoryImplementor#getConnectionProvider
   */
  public static DataSource getDataSource(SessionFactory sessionFactory) {
    if (sessionFactory instanceof SessionFactoryImplementor) {
      ConnectionProvider cp = ((SessionFactoryImplementor) sessionFactory).getConnectionProvider();
      return cp.unwrap(DataSource.class);
    }
    return null;
  }
View Full Code Here

     * @see org.snowfk.web.db.hibernate.HibernateDaoHelper#getConnection()
     */
    @SuppressWarnings("deprecation")
    public Connection getConnection() {
        try {
            ConnectionProvider cp =((SessionFactoryImplementor)getSession().getSessionFactory()).getConnectionProvider()
            return cp.getConnection();   
        } catch (Exception e) {
            e.printStackTrace();
        }
          return null;
//        return getSession().connection();
View Full Code Here

      return null;
    }

    final ClassLoaderService classLoaderService = registry.getService( ClassLoaderService.class );

    ConnectionProvider connectionProvider = null;
    String providerClassName = getConfiguredConnectionProviderName( configurationValues );
    if ( providerClassName != null ) {
      connectionProvider = instantiateExplicitConnectionProvider( providerClassName, classLoaderService );
    }
    else if ( configurationValues.get( Environment.DATASOURCE ) != null ) {
      connectionProvider = new DatasourceConnectionProviderImpl();
    }

    if ( connectionProvider == null ) {
      if ( c3p0ConfigDefined( configurationValues ) && c3p0ProviderPresent( classLoaderService ) ) {
        connectionProvider = instantiateExplicitConnectionProvider( C3P0_PROVIDER_CLASS_NAME,
            classLoaderService
        );
      }
    }

    if ( connectionProvider == null ) {
      if ( proxoolConfigDefined( configurationValues ) && proxoolProviderPresent( classLoaderService ) ) {
        connectionProvider = instantiateExplicitConnectionProvider( PROXOOL_PROVIDER_CLASS_NAME,
            classLoaderService
        );
      }
    }

    if ( connectionProvider == null ) {
      if ( configurationValues.get( Environment.URL ) != null ) {
        connectionProvider = new DriverManagerConnectionProviderImpl();
      }
    }

    if ( connectionProvider == null ) {
            LOG.noAppropriateConnectionProvider();
      connectionProvider = new UserSuppliedConnectionProviderImpl();
    }


    final Map injectionData = (Map) configurationValues.get( INJECTION_DATA );
    if ( injectionData != null && injectionData.size() > 0 ) {
      final ConnectionProvider theConnectionProvider = connectionProvider;
      new BeanInfoHelper( connectionProvider.getClass() ).applyToBeanInfo(
          connectionProvider,
          new BeanInfoHelper.BeanInfoDelegate() {
            public void processBeanInfo(BeanInfo beanInfo) throws Exception {
              PropertyDescriptor[] descritors = beanInfo.getPropertyDescriptors();
View Full Code Here

   * {@inheritDoc}
   */
  public ConnectionProvider initiateService(Map configurationValues, ServiceRegistry registry) {
    final ClassLoaderService classLoaderService = registry.getService( ClassLoaderService.class );

    ConnectionProvider connectionProvider = null;
    String providerClassName = getConfiguredConnectionProviderName( configurationValues );
    if ( providerClassName != null ) {
      connectionProvider = instantiateExplicitConnectionProvider( providerClassName, classLoaderService );
    }
    else if ( configurationValues.get( Environment.DATASOURCE ) != null ) {
      connectionProvider = new DatasourceConnectionProviderImpl();
    }

    if ( connectionProvider == null ) {
      if ( c3p0ConfigDefined( configurationValues ) && c3p0ProviderPresent( classLoaderService ) ) {
        connectionProvider = instantiateExplicitConnectionProvider( C3P0_PROVIDER_CLASS_NAME,
            classLoaderService
        );
      }
    }

    if ( connectionProvider == null ) {
      if ( proxoolConfigDefined( configurationValues ) && proxoolProviderPresent( classLoaderService ) ) {
        connectionProvider = instantiateExplicitConnectionProvider( PROXOOL_PROVIDER_CLASS_NAME,
            classLoaderService
        );
      }
    }

    if ( connectionProvider == null ) {
      if ( configurationValues.get( Environment.URL ) != null ) {
        connectionProvider = new DriverManagerConnectionProviderImpl();
      }
    }

    if ( connectionProvider == null ) {
            LOG.noAppropriateConnectionProvider();
      connectionProvider = new UserSuppliedConnectionProviderImpl();
    }


    final Map injectionData = (Map) configurationValues.get( INJECTION_DATA );
    if ( injectionData != null && injectionData.size() > 0 ) {
      final ConnectionProvider theConnectionProvider = connectionProvider;
      new BeanInfoHelper( connectionProvider.getClass() ).applyToBeanInfo(
          connectionProvider,
          new BeanInfoHelper.BeanInfoDelegate() {
            public void processBeanInfo(BeanInfo beanInfo) throws Exception {
              PropertyDescriptor[] descritors = beanInfo.getPropertyDescriptors();
View Full Code Here

      // nothing to do, but given the separate hierarchies have to handle this here.
    }

    final ClassLoaderService classLoaderService = registry.getService( ClassLoaderService.class );

    ConnectionProvider connectionProvider = null;
    String providerClassName = getConfiguredConnectionProviderName( configurationValues );
    if ( providerClassName != null ) {
      connectionProvider = instantiateExplicitConnectionProvider( providerClassName, classLoaderService );
    }
    else if ( configurationValues.get( Environment.DATASOURCE ) != null ) {
      connectionProvider = new DatasourceConnectionProviderImpl();
    }

    if ( connectionProvider == null ) {
      if ( c3p0ConfigDefined( configurationValues ) && c3p0ProviderPresent( classLoaderService ) ) {
        connectionProvider = instantiateExplicitConnectionProvider( C3P0_PROVIDER_CLASS_NAME,
            classLoaderService
        );
      }
    }

    if ( connectionProvider == null ) {
      if ( proxoolConfigDefined( configurationValues ) && proxoolProviderPresent( classLoaderService ) ) {
        connectionProvider = instantiateExplicitConnectionProvider( PROXOOL_PROVIDER_CLASS_NAME,
            classLoaderService
        );
      }
    }

    if ( connectionProvider == null ) {
      if ( configurationValues.get( Environment.URL ) != null ) {
        connectionProvider = new DriverManagerConnectionProviderImpl();
      }
    }

    if ( connectionProvider == null ) {
            LOG.noAppropriateConnectionProvider();
      connectionProvider = new UserSuppliedConnectionProviderImpl();
    }


    final Map injectionData = (Map) configurationValues.get( INJECTION_DATA );
    if ( injectionData != null && injectionData.size() > 0 ) {
      final ConnectionProvider theConnectionProvider = connectionProvider;
      new BeanInfoHelper( connectionProvider.getClass() ).applyToBeanInfo(
          connectionProvider,
          new BeanInfoHelper.BeanInfoDelegate() {
            public void processBeanInfo(BeanInfo beanInfo) throws Exception {
              PropertyDescriptor[] descritors = beanInfo.getPropertyDescriptors();
View Full Code Here

    //this.em.flush();
       
    HibernateEntityManagerFactory factory = (HibernateEntityManagerFactory) this.em.unwrap(EntityManagerImpl.class).getEntityManagerFactory();
    SessionFactoryImpl sessionFactory = (SessionFactoryImpl) factory.getSessionFactory();
   
    ConnectionProvider connProvider = sessionFactory.getConnectionProvider();
    DataSource ds = null;
    if (connProvider instanceof DatasourceConnectionProviderImpl) {
      ds = ((DatasourceConnectionProviderImpl) connProvider).getDataSource();
      logger.debug("Using actual DataSource to execute DataSource work: " + ds);
    } else {
View Full Code Here

      return null;
    }

    final ClassLoaderService classLoaderService = registry.getService( ClassLoaderService.class );

    ConnectionProvider connectionProvider = null;
    String providerClassName = getConfiguredConnectionProviderName( configurationValues );
    if ( providerClassName != null ) {
      connectionProvider = instantiateExplicitConnectionProvider( providerClassName, classLoaderService );
    }
    else if ( configurationValues.get( Environment.DATASOURCE ) != null ) {
      connectionProvider = new DatasourceConnectionProviderImpl();
    }

    if ( connectionProvider == null ) {
      if ( c3p0ConfigDefined( configurationValues ) && c3p0ProviderPresent( classLoaderService ) ) {
        connectionProvider = instantiateExplicitConnectionProvider( C3P0_PROVIDER_CLASS_NAME,
            classLoaderService
        );
      }
    }

    if ( connectionProvider == null ) {
      if ( proxoolConfigDefined( configurationValues ) && proxoolProviderPresent( classLoaderService ) ) {
        connectionProvider = instantiateExplicitConnectionProvider( PROXOOL_PROVIDER_CLASS_NAME,
            classLoaderService
        );
      }
    }

    if ( connectionProvider == null ) {
      if ( configurationValues.get( Environment.URL ) != null ) {
        connectionProvider = new DriverManagerConnectionProviderImpl();
      }
    }

    if ( connectionProvider == null ) {
            LOG.noAppropriateConnectionProvider();
      connectionProvider = new UserSuppliedConnectionProviderImpl();
    }


    final Map injectionData = (Map) configurationValues.get( INJECTION_DATA );
    if ( injectionData != null && injectionData.size() > 0 ) {
      final ConnectionProvider theConnectionProvider = connectionProvider;
      new BeanInfoHelper( connectionProvider.getClass() ).applyToBeanInfo(
          connectionProvider,
          new BeanInfoHelper.BeanInfoDelegate() {
            public void processBeanInfo(BeanInfo beanInfo) throws Exception {
              PropertyDescriptor[] descritors = beanInfo.getPropertyDescriptors();
View Full Code Here

TOP

Related Classes of org.hibernate.service.jdbc.connections.spi.ConnectionProvider

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.