当前位置: 首页>>代码示例>>Java>>正文


Java CommonDataSource类代码示例

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


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

示例1: resolveDataSourceName

import javax.sql.CommonDataSource; //导入依赖的package包/类
public String resolveDataSourceName(CommonDataSource dataSource) {
    if (dataSources == null) {
        this.dataSources = applicationContext.getBeansOfType(DataSource.class);
    }
    return dataSources.entrySet()
            .stream()
            .filter(entry -> {
                DataSource candidate = entry.getValue();
                if (candidate instanceof DecoratedDataSource) {
                    return matchesDataSource((DecoratedDataSource) candidate, dataSource);
                }
                return candidate == dataSource;
            })
            .findFirst()
            .map(Entry::getKey)
            .orElse("dataSource");
}
 
开发者ID:gavlyukovskiy,项目名称:spring-boot-data-source-decorator,代码行数:18,代码来源:DataSourceNameResolver.java

示例2: isWrapperFor

import javax.sql.CommonDataSource; //导入依赖的package包/类
public boolean isWrapperFor(Class<?> iface) throws SQLException {
    if (iface.isInstance(this)) {
        return true;
    }
    CommonDataSource cds = getUnwrappedDataSource();
    if (iface.isInstance(cds)) {
        return true;
    }
    if (cds instanceof DataSource) {
        DataSource ds = (DataSource) cds;
        if (ds.isWrapperFor(iface)) {
            return true;
        }
    }
    return false;
}
 
开发者ID:ops4j,项目名称:org.ops4j.pax.transx,代码行数:17,代码来源:TransxDataSource.java

示例3: unwrap

import javax.sql.CommonDataSource; //导入依赖的package包/类
public <T> T unwrap(Class<T> iface) throws SQLException {
    if (iface.isInstance(this)) {
        return iface.cast(this);
    }
    CommonDataSource cds = getUnwrappedDataSource();
    if (iface.isInstance(cds)) {
        return iface.cast(cds);
    }
    if (cds instanceof DataSource) {
        DataSource ds = (DataSource) cds;
        if (ds.isWrapperFor(iface)) {
            return ds.unwrap(iface);
        }
    }
    throw new SQLException("Not a wrapper for " + iface.getName());
}
 
开发者ID:ops4j,项目名称:org.ops4j.pax.transx,代码行数:17,代码来源:TransxDataSource.java

示例4: setup

import javax.sql.CommonDataSource; //导入依赖的package包/类
@Before
public void setup() throws SQLException {
    Platform platform = new HSQL();
    CommonDataSource dataSource = DatabaseType.getDataSource(platform);
    EntityModel model = Models.MODEL2;

    Configuration configuration = new ConfigurationBuilder(dataSource, model)
        .useDefaultLogging()
        .setEntityCache(new EmptyEntityCache())
        .setWriteExecutor(Executors.newSingleThreadExecutor())
        .build();

    SchemaModifier tables = new SchemaModifier(configuration);
    tables.createTables(TableCreationMode.DROP_CREATE);
    data = new EntityDataStore<>(configuration);
}
 
开发者ID:requery,项目名称:requery,代码行数:17,代码来源:TimeConversionsTest.java

示例5: setup

import javax.sql.CommonDataSource; //导入依赖的package包/类
@Before
public void setup() throws SQLException {
    CommonDataSource dataSource = DatabaseType.getDataSource(new H2());
    EntityModel model = Models.JPA;

    CachingProvider provider = Caching.getCachingProvider();
    CacheManager cacheManager = provider.getCacheManager();
    Configuration configuration = new ConfigurationBuilder(dataSource, model)
        .useDefaultLogging()
        .setEntityCache(new EntityCacheBuilder(model)
            .useReferenceCache(true)
            .useSerializableCache(true)
            .useCacheManager(cacheManager)
            .build())
        .build();
    data = new EntityDataStore<>(configuration);
    SchemaModifier tables = new SchemaModifier(configuration);
    tables.dropTables();
    TableCreationMode mode = TableCreationMode.CREATE;
    System.out.println(tables.createTablesString(mode));
    tables.createTables(mode);
}
 
开发者ID:requery,项目名称:requery,代码行数:23,代码来源:JPAModelTest.java

示例6: setup

import javax.sql.CommonDataSource; //导入依赖的package包/类
@Before
public void setup() throws SQLException {
    CommonDataSource dataSource = DatabaseType.getDataSource(platform);
    EntityModel model = Models.MODEL3;

    Configuration configuration = new ConfigurationBuilder(dataSource, model)
        .useDefaultLogging()
        .setEntityCache(new EmptyEntityCache())
        .setWriteExecutor(Executors.newSingleThreadExecutor())
        .build();

    SchemaModifier tables = new SchemaModifier(configuration);
    tables.createTables(TableCreationMode.DROP_CREATE);
    System.out.println(tables.createTablesString(TableCreationMode.DROP_CREATE));
    data = new EntityDataStore<>(configuration);
}
 
开发者ID:requery,项目名称:requery,代码行数:17,代码来源:UpsertTest.java

示例7: setup

import javax.sql.CommonDataSource; //导入依赖的package包/类
@Before
public void setup() throws SQLException {
    Platform platform = new HSQL();
    CommonDataSource dataSource = DatabaseType.getDataSource(platform);
    EntityModel model = io.requery.test.model.Models.DEFAULT;

    CachingProvider provider = Caching.getCachingProvider();
    CacheManager cacheManager = provider.getCacheManager();
    Configuration configuration = new ConfigurationBuilder(dataSource, model)
        .useDefaultLogging()
        .setWriteExecutor(Executors.newSingleThreadExecutor())
        .setEntityCache(new EntityCacheBuilder(model)
            .useReferenceCache(true)
            .useSerializableCache(true)
            .useCacheManager(cacheManager)
            .build())
        .build();

    SchemaModifier tables = new SchemaModifier(configuration);
    tables.createTables(TableCreationMode.DROP_CREATE);
    data = new ReactorEntityStore<>(new EntityDataStore<Persistable>(configuration));
}
 
开发者ID:requery,项目名称:requery,代码行数:23,代码来源:ReactorTest.java

示例8: setup

import javax.sql.CommonDataSource; //导入依赖的package包/类
@Before
public void setup() throws SQLException {
    CommonDataSource dataSource = DatabaseType.getDataSource(platform);
    EntityModel model = Models.STATELESS;

    Configuration configuration = new ConfigurationBuilder(dataSource, model)
        .useDefaultLogging()
        .setEntityCache(new EmptyEntityCache())
        .setWriteExecutor(Executors.newSingleThreadExecutor())
        .build();

    SchemaModifier tables = new SchemaModifier(configuration);
    tables.createTables(TableCreationMode.DROP_CREATE);
    System.out.println(tables.createTablesString(TableCreationMode.DROP_CREATE));
    data = new EntityDataStore<>(configuration);
}
 
开发者ID:requery,项目名称:requery,代码行数:17,代码来源:StatelessTest.java

示例9: setup

import javax.sql.CommonDataSource; //导入依赖的package包/类
@Before
public void setup() throws SQLException {
    CommonDataSource dataSource = DatabaseType.getDataSource(new SQLite());
    EntityModel model = Models.AUTOVALUE;
    Configuration configuration = new ConfigurationBuilder(dataSource, model)
        .useDefaultLogging()
        .setEntityCache(new EntityCacheBuilder(model)
            .useReferenceCache(true)
            .build())
        .build();
    data = new EntityDataStore<>(configuration);
    SchemaModifier tables = new SchemaModifier(configuration);
    tables.dropTables();
    TableCreationMode mode = TableCreationMode.CREATE_NOT_EXISTS;
    System.out.println(tables.createTablesString(mode));
    tables.createTables(mode);
}
 
开发者ID:requery,项目名称:requery,代码行数:18,代码来源:AutoValueModelTest.java

示例10: setup

import javax.sql.CommonDataSource; //导入依赖的package包/类
@Before
public void setup() throws SQLException {
    Platform platform = new HSQL();
    CommonDataSource dataSource = DatabaseType.getDataSource(platform);
    EntityModel model = io.requery.test.model.Models.DEFAULT;

    CachingProvider provider = Caching.getCachingProvider();
    CacheManager cacheManager = provider.getCacheManager();
    Configuration configuration = new ConfigurationBuilder(dataSource, model)
        .useDefaultLogging()
        .setWriteExecutor(Executors.newSingleThreadExecutor())
        .setEntityCache(new EntityCacheBuilder(model)
            .useReferenceCache(true)
            .useSerializableCache(true)
            .useCacheManager(cacheManager)
            .build())
        .build();

    SchemaModifier tables = new SchemaModifier(configuration);
    tables.createTables(TableCreationMode.DROP_CREATE);
    data = ReactiveSupport.toReactiveStore(new EntityDataStore<Persistable>(configuration));
}
 
开发者ID:requery,项目名称:requery,代码行数:23,代码来源:ReactiveTest.java

示例11: setup

import javax.sql.CommonDataSource; //导入依赖的package包/类
@Before
public void setup() throws SQLException {
    Platform platform = new HSQL();
    CommonDataSource dataSource = DatabaseType.getDataSource(platform);
    EntityModel model = io.requery.test.model.Models.DEFAULT;

    CachingProvider provider = Caching.getCachingProvider();
    CacheManager cacheManager = provider.getCacheManager();
    Configuration configuration = new ConfigurationBuilder(dataSource, model)
        .useDefaultLogging()
        .setWriteExecutor(Executors.newSingleThreadExecutor())
        .setEntityCache(new EntityCacheBuilder(model)
            .useReferenceCache(true)
            .useSerializableCache(true)
            .useCacheManager(cacheManager)
            .build())
        .build();

    SchemaModifier tables = new SchemaModifier(configuration);
    tables.createTables(TableCreationMode.DROP_CREATE);
    data = RxSupport.toReactiveStore(new EntityDataStore<Persistable>(configuration));
}
 
开发者ID:requery,项目名称:requery,代码行数:23,代码来源:RxTest.java

示例12: setup

import javax.sql.CommonDataSource; //导入依赖的package包/类
@Before
public void setup() throws SQLException {
    CommonDataSource dataSource = DatabaseType.getDataSource(platform);
    EntityModel model = io.requery.test.model.Models.DEFAULT;

    Configuration configuration = new ConfigurationBuilder(dataSource, model)
        .useDefaultLogging()
        .setStatementCacheSize(10)
        .setBatchUpdateSize(50)
        .setWriteExecutor(Executors.newSingleThreadExecutor())
        .build();

    schemaModifier = new SchemaModifier(configuration);
    try {
        schemaModifier.dropTables();
    } catch (Exception e) {
        // expected if 'drop if exists' not supported (so ignore in that case)
        if (!platform.supportsIfExists()) {
            throw e;
        }
    }
    schemaModifier.createTables(TableCreationMode.CREATE);
}
 
开发者ID:requery,项目名称:requery,代码行数:24,代码来源:SchemaModifierTest.java

示例13: getJDBCDataSource

import javax.sql.CommonDataSource; //导入依赖的package包/类
public static CommonDataSource getJDBCDataSource(String clazz, String url, String user,
    String password) {
  if (url == null) {
    throw new ConnectionPoolException("url is null");
  }
  Driver driver;
  try {
    if (clazz == null) {
      clazz = JdbcUtils.getDriverClassName(url);
    }
    driver = JdbcUtils.createDriver(clazz);
  } catch (SQLException e) {
    throw new ConnectionPoolException(e);
  }
  Properties connectProperties = new Properties();
  if (user != null) {
    connectProperties.put("user", user);
  }
  if (password != null) {
    connectProperties.put("password", password);
  }
  return new JDBCDataSource(clazz, url, driver, connectProperties);
}
 
开发者ID:xionghuiCoder,项目名称:clearpool,代码行数:24,代码来源:DataSourceUtils.java

示例14: pool

import javax.sql.CommonDataSource; //导入依赖的package包/类
@Override
public CommonDataSource pool(final String name, final String driver, final Properties properties) {
    properties.setProperty("name", name);

    final String xa = String.class.cast(properties.remove("XaDataSource"));
    if (xa == null && !properties.containsKey("JdbcDriver")) {
        properties.setProperty("driverClassName", driver);
    }

    final BasicDataSource ds = build(BasicDataSource.class, properties);
    ds.setDriverClassName(driver);
    if (xa != null) {
        ds.setDelegate(XADataSourceResource.proxy(Thread.currentThread().getContextClassLoader(), xa));
    }
    return ds;
}
 
开发者ID:apache,项目名称:tomee,代码行数:17,代码来源:DbcpDataSourceCreator.java

示例15: pool

import javax.sql.CommonDataSource; //导入依赖的package包/类
@Override
public CommonDataSource pool(final String name, final String driver, final Properties properties) {
    return (CustomDataSource) Proxy.newProxyInstance(Thread.currentThread().getContextClassLoader(),
        new Class<?>[]{CustomDataSource.class},
        new InvocationHandler() {
            @Override
            public Object invoke(final Object proxy, final Method method, final Object[] args) throws Throwable {
                if (method.getName().equals("name")) {
                    return properties.getProperty("Name");
                }
                if ("hashCode".equals(method.getName())) {
                    return properties.hashCode(); // don't care
                }
                return null;
            }
        });
}
 
开发者ID:apache,项目名称:tomee,代码行数:18,代码来源:CustomPoolDataSourceTest.java


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