• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java ConnectionProvider类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中org.hibernate.connection.ConnectionProvider的典型用法代码示例。如果您正苦于以下问题:Java ConnectionProvider类的具体用法?Java ConnectionProvider怎么用?Java ConnectionProvider使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



ConnectionProvider类属于org.hibernate.connection包,在下文中一共展示了ConnectionProvider类的19个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: testUserProvidedConnection

import org.hibernate.connection.ConnectionProvider; //导入依赖的package包/类
public void testUserProvidedConnection() throws Exception {
	ConnectionProvider dcp = new DriverManagerConnectionProvider();
	dcp.configure( Environment.getProperties() );
	Session s = getSessions().openSession( dcp.getConnection() );
	Transaction tx = s.beginTransaction();
	s.find("from Fo");
	tx.commit();
	Connection c = s.disconnect();
	assertTrue( c!=null );
	s.reconnect(c);
	tx = s.beginTransaction();
	s.find("from Fo");
	tx.commit();
	assertTrue( s.close()==c );
	c.close();
}
 
开发者ID:cacheonix,项目名称:cacheonix-core,代码行数:17,代码来源:FooBarTest.java


示例2: testSelectStatementWithStatementsCache

import org.hibernate.connection.ConnectionProvider; //导入依赖的package包/类
@Test
public void testSelectStatementWithStatementsCache() throws SQLException {
    Session session = HibernateTestUtils.getSessionFactoryWithStmtCache().openSession();

    ConnectionProvider cp = ((SessionFactoryImplementor) session.getSessionFactory()).getConnectionProvider();
    ViburDBCPDataSource ds = ((ViburDBCPConnectionProvider) cp).getDataSource();

    ConcurrentMap<StatementMethod, StatementHolder> mockedStatementCache = mockStatementCache(ds);

    executeAndVerifySelectInSession(session);
    // resources/hibernate-with-stmt-cache.cfg.xml defines pool with 1 connection only, that's why
    // the second session will get and use the same underlying connection.
    session = HibernateTestUtils.getSessionFactoryWithStmtCache().openSession();
    executeAndVerifySelectInSession(session);

    InOrder inOrder = inOrder(mockedStatementCache);
    inOrder.verify(mockedStatementCache).get(key1.capture());
    inOrder.verify(mockedStatementCache).putIfAbsent(same(key1.getValue()), val1.capture());
    inOrder.verify(mockedStatementCache).get(key2.capture());

    assertEquals(1, mockedStatementCache.size());
    assertTrue(mockedStatementCache.containsKey(key1.getValue()));
    assertEquals(key1.getValue(), key2.getValue());
    assertEquals(AVAILABLE, val1.getValue().state().get());
}
 
开发者ID:vibur,项目名称:vibur-dbcp-hibernate3,代码行数:26,代码来源:ViburDBCPConnectionProviderTest.java


示例3: shutdownDBIfNeeded

import org.hibernate.connection.ConnectionProvider; //导入依赖的package包/类
@Override
public void shutdownDBIfNeeded() {
    SessionFactoryImplementor sessionFactory = (SessionFactoryImplementor) getSessionFactory();
    ConnectionProvider connectionProvider = sessionFactory.getConnectionProvider();
    try {
        Connection connection = connectionProvider.getConnection();
        try {
            String dbName = connection.getMetaData().getDatabaseProductName();
            if (dbName.startsWith("HSQL")) {
                new JDBCWrapper(connection).execute("SHUTDOWN");
                LOG.info("Shutdown on HSQL Database was successful");
            }
        } finally {
            connectionProvider.closeConnection(connection);
        }
    } catch (SQLException e) {
        LOG.warn("Error shutting down database connection", e);
    }
}
 
开发者ID:crypto-coder,项目名称:open-cyclos,代码行数:20,代码来源:ApplicationDAOImpl.java


示例4: unwrap

import org.hibernate.connection.ConnectionProvider; //导入依赖的package包/类
@Override
  public <T> T unwrap(Class<T> unwrapType) {
      if (ConnectionProvider.class.equals(unwrapType) ||
              CustomJDBCConnectionProvider.class.isAssignableFrom(unwrapType)) {
          return (T) this;
      } else {
          throw new UnknownUnwrapTypeException( unwrapType );
      }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:10,代码来源:CustomJDBCConnectionProvider.java


示例5: getDataSource

import org.hibernate.connection.ConnectionProvider; //导入依赖的package包/类
/**
 * Determine the DataSource of the given SessionFactory.
 * @param sessionFactory the SessionFactory to check
 * @return the DataSource, or {@code null} if none found
 * @see org.hibernate.engine.SessionFactoryImplementor#getConnectionProvider
 * @see LocalDataSourceConnectionProvider
 */
public static DataSource getDataSource(SessionFactory sessionFactory) {
	if (sessionFactory instanceof SessionFactoryImplementor) {
		ConnectionProvider cp = ((SessionFactoryImplementor) sessionFactory).getConnectionProvider();
		if (cp instanceof LocalDataSourceConnectionProvider) {
			return ((LocalDataSourceConnectionProvider) cp).getDataSource();
		}
	}
	return null;
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:17,代码来源:SessionFactoryUtils.java


示例6: getConnection

import org.hibernate.connection.ConnectionProvider; //导入依赖的package包/类
protected Connection getConnection() throws SQLException {
    if (sessionFactory instanceof SessionFactoryImplementor) {
        ConnectionProvider cp = ((SessionFactoryImplementor) sessionFactory).getConnectionProvider();
        return cp.getConnection();
    }
    return super.getConnection();
}
 
开发者ID:snakerflow,项目名称:snakerflow,代码行数:8,代码来源:Hibernate3Access.java


示例7: isUnwrappableAs

import org.hibernate.connection.ConnectionProvider; //导入依赖的package包/类
@Override
 public boolean isUnwrappableAs(Class unwrapType) {
     return ConnectionProvider.class.equals(unwrapType) ||
             CustomJDBCConnectionProvider.class.isAssignableFrom(unwrapType);
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:6,代码来源:CustomJDBCConnectionProvider.java


示例8: getConnectionProvider

import org.hibernate.connection.ConnectionProvider; //导入依赖的package包/类
public ConnectionProvider getConnectionProvider() {
  return ((SessionFactoryImplementor) delegateSessionFactory).getConnectionProvider();
}
 
开发者ID:mauyr,项目名称:openbravo-brazil,代码行数:4,代码来源:DalSessionFactory.java


示例9: getConnectionProvider

import org.hibernate.connection.ConnectionProvider; //导入依赖的package包/类
/**
 * @return the {@link ConnectionProvider} to use
 */
private ConnectionProvider getConnectionProvider() {
    return sessionFactoryImplementor.getConnectionProvider();
}
 
开发者ID:Communote,项目名称:communote-server,代码行数:7,代码来源:AbstractLiquibaseDatabaseUpdater.java


示例10: getConnectionProvider

import org.hibernate.connection.ConnectionProvider; //导入依赖的package包/类
/**
 * To get Connection Provider.
 * @return ConnectionProvider
 */
public ConnectionProvider getConnectionProvider() {
	ConnectionProvider connectionProvider = null;
	connectionProvider = ((SessionFactoryImplementor) this.sessionFactory).getConnectionProvider();
	return connectionProvider;
}
 
开发者ID:kuzavas,项目名称:ephesoft,代码行数:10,代码来源:DynamicHibernateDao.java


示例11: createConnectionProvider

import org.hibernate.connection.ConnectionProvider; //导入依赖的package包/类
protected ConnectionProvider createConnectionProvider(Properties properties) {
	return ConnectionProviderFactory.newConnectionProvider(properties);
}
 
开发者ID:cacheonix,项目名称:cacheonix-core,代码行数:4,代码来源:SettingsFactory.java


示例12: getConnectionProvider

import org.hibernate.connection.ConnectionProvider; //导入依赖的package包/类
public ConnectionProvider getConnectionProvider() {
	return connectionProvider;
}
 
开发者ID:cacheonix,项目名称:cacheonix-core,代码行数:4,代码来源:Settings.java


示例13: setConnectionProvider

import org.hibernate.connection.ConnectionProvider; //导入依赖的package包/类
void setConnectionProvider(ConnectionProvider provider) {
	connectionProvider = provider;
}
 
开发者ID:cacheonix,项目名称:cacheonix-core,代码行数:4,代码来源:Settings.java


示例14: SuppliedConnectionProviderConnectionHelper

import org.hibernate.connection.ConnectionProvider; //导入依赖的package包/类
public SuppliedConnectionProviderConnectionHelper(ConnectionProvider provider) {
	this.provider = provider;
}
 
开发者ID:cacheonix,项目名称:cacheonix-core,代码行数:4,代码来源:SuppliedConnectionProviderConnectionHelper.java


示例15: getConnectionProvider

import org.hibernate.connection.ConnectionProvider; //导入依赖的package包/类
public ConnectionProvider getConnectionProvider() {
	return settings.getConnectionProvider();
}
 
开发者ID:cacheonix,项目名称:cacheonix-core,代码行数:4,代码来源:SessionFactoryImpl.java


示例16: testJdbcOnly

import org.hibernate.connection.ConnectionProvider; //导入依赖的package包/类
public void testJdbcOnly() throws Exception {

		ConnectionProvider cp = ConnectionProviderFactory.newConnectionProvider( Environment.getProperties() );

		for ( int n=2; n<4000; n*=2 ) {

			Session s = openSession();
			Simple[] simples = new Simple[n];
			s.delete("from Simple");
			s.flush();
			Serializable[] ids = new Serializable[n];
			for ( int i=0; i<n; i++ ) {
				simples[i] = new Simple();
				simples[i].init();
				simples[i].setCount(i);
				ids[i] = new Long(i);
				s.save(simples[i], ids[i]);
			}
			s.flush();
			s.connection().commit();
			s.close();


			//Now do timings

			Connection c = cp.getConnection();
			long time = System.currentTimeMillis();
			directJDBC( c, simples, ids, n, "j1" );
			long jdbc = System.currentTimeMillis() - time;
			cp.closeConnection(c);

			c = cp.getConnection();
			time = System.currentTimeMillis();
			directJDBC( c, simples, ids, n, "j2" );
			jdbc += System.currentTimeMillis() - time;
			cp.closeConnection(c);

			c = cp.getConnection();
			time = System.currentTimeMillis();
			directJDBC( c, simples, ids, n, "j2" );
			jdbc += System.currentTimeMillis() - time;
			cp.closeConnection(c);

			System.out.println( "Objects: " + n + " Direct JDBC: " + jdbc );

		}

		cp.close();
		System.gc();
	}
 
开发者ID:cacheonix,项目名称:cacheonix-core,代码行数:51,代码来源:NewerPerformanceTest.java


示例17: testSimultaneous

import org.hibernate.connection.ConnectionProvider; //导入依赖的package包/类
public void testSimultaneous() throws Exception {

		ConnectionProvider cp = ConnectionProviderFactory.newConnectionProvider( Environment.getProperties() );

		for ( int n=2; n<4000; n*=2 ) {

			Simple[] simples = new Simple[n];
			Serializable[] ids = new Serializable[n];
			for ( int i=0; i<n; i++ ) {
				simples[i] = new Simple();
				simples[i].init();
				simples[i].setCount(i);
				ids[i] = new Long(i);
			}

			//allow cache to settle

			Session s = openSession();
			hibernate(s, simples, ids, n, "h0");
			s.close();

			Connection c = cp.getConnection();
			directJDBC( c, simples, ids, n, "j0" );
			cp.closeConnection(c);

			s = openSession();
			hibernate(s, simples, ids, n, "h0");
			s.close();

			c = cp.getConnection();
			directJDBC( c, simples, ids, n, "j0" );
			cp.closeConnection(c);

			//Now do timings

			s = openSession();
			long time = System.currentTimeMillis();
			hibernate(s, simples, ids, n, "h1");
			long hiber = System.currentTimeMillis() - time;
			s.close();

			c = cp.getConnection();
			time = System.currentTimeMillis();
			directJDBC( c, simples, ids, n, "j1" );
			long jdbc = System.currentTimeMillis() - time;
			cp.closeConnection(c);

			s = openSession();
			time = System.currentTimeMillis();
			hibernate(s, simples, ids, n, "h2");
			hiber += System.currentTimeMillis() - time;
			s.close();

			c = cp.getConnection();
			time = System.currentTimeMillis();
			directJDBC( c, simples, ids, n, "j2" );
			jdbc += System.currentTimeMillis() - time;
			cp.closeConnection(c);

			s = openSession();
			time = System.currentTimeMillis();
			hibernate(s, simples, ids, n, "h2");
			hiber += System.currentTimeMillis() - time;
			s.close();

			c = cp.getConnection();
			time = System.currentTimeMillis();
			directJDBC( c, simples, ids, n, "j2" );
			jdbc += System.currentTimeMillis() - time;
			cp.closeConnection(c);

			System.out.println( "Objects: " + n + " - Hibernate: " + hiber + "ms / Direct JDBC: " + jdbc + "ms = Ratio: " + ( (float) hiber )/jdbc );

		}

		cp.close();
		System.gc();
	}
 
开发者ID:cacheonix,项目名称:cacheonix-core,代码行数:79,代码来源:PerformanceTest.java


示例18: testJdbcOnly

import org.hibernate.connection.ConnectionProvider; //导入依赖的package包/类
public void testJdbcOnly() throws Exception {

		ConnectionProvider cp = ConnectionProviderFactory.newConnectionProvider( Environment.getProperties() );

		for ( int n=2; n<4000; n*=2 ) {

			Simple[] simples = new Simple[n];
			Serializable[] ids = new Serializable[n];
			for ( int i=0; i<n; i++ ) {
				simples[i] = new Simple();
				simples[i].init();
				simples[i].setCount(i);
				ids[i] = new Long(i);
			}

			//Now do timings

			Connection c = cp.getConnection();
			long time = System.currentTimeMillis();
			directJDBC( c, simples, ids, n, "j1" );
			long jdbc = System.currentTimeMillis() - time;
			cp.closeConnection(c);

			c = cp.getConnection();
			time = System.currentTimeMillis();
			directJDBC( c, simples, ids, n, "j2" );
			jdbc += System.currentTimeMillis() - time;
			cp.closeConnection(c);

			c = cp.getConnection();
			time = System.currentTimeMillis();
			directJDBC( c, simples, ids, n, "j2" );
			jdbc += System.currentTimeMillis() - time;
			cp.closeConnection(c);

			System.out.println( "Objects: " + n + " Direct JDBC: " + jdbc );

		}

		cp.close();
		System.gc();
	}
 
开发者ID:cacheonix,项目名称:cacheonix-core,代码行数:43,代码来源:PerformanceTest.java


示例19: getConnectionProvider

import org.hibernate.connection.ConnectionProvider; //导入依赖的package包/类
/**
 * Get the connection provider
 */
public ConnectionProvider getConnectionProvider();
 
开发者ID:cacheonix,项目名称:cacheonix-core,代码行数:5,代码来源:SessionFactoryImplementor.java



注:本文中的org.hibernate.connection.ConnectionProvider类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java StandardBarPainter类代码示例发布时间:2022-05-21
下一篇:
Java Advice类代码示例发布时间:2022-05-21
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap