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


Java DataSourceFactory类代码示例

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


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

示例1: createDataSource

import org.apache.tomcat.jdbc.pool.DataSourceFactory; //导入依赖的package包/类
private synchronized void createDataSource(final String catalogName, final Map props) {
    if (dataSources.get(catalogName) == null) {
        final Properties dataSourceProperties = new Properties();
        props.forEach((key, value) -> {
            final String prop = String.valueOf(key);
            if (prop.startsWith(JDO_PREFIX)) {
                dataSourceProperties.put(prop.substring(JDO_PREFIX.length()), value);
            }
        });
        if (!dataSourceProperties.isEmpty()) {
            try {
                final DataSource dataSource = new DataSourceFactory().createDataSource(dataSourceProperties);
                dataSources.put(catalogName, dataSource);
            } catch (Exception e) {
                throw new RuntimeException(String
                    .format("Failed to load the data source for catalog %s with error [%s]", catalogName,
                        e.getMessage()), e);
            }
        }
    }
}
 
开发者ID:Netflix,项目名称:metacat,代码行数:22,代码来源:DataSourceManager.java

示例2: getTransactionIsolationLevelInt

import org.apache.tomcat.jdbc.pool.DataSourceFactory; //导入依赖的package包/类
protected int getTransactionIsolationLevelInt() {

        if (defaultTransactionIsolation == null) {
            return DataSourceFactory.UNKNOWN_TRANSACTIONISOLATION;
        }
        if ("NONE".equalsIgnoreCase(defaultTransactionIsolation)) {
            return Connection.TRANSACTION_NONE;
        }
        if ("READ_COMMITTED".equalsIgnoreCase(defaultTransactionIsolation)) {
            return Connection.TRANSACTION_READ_COMMITTED;
        }
        if ("READ_UNCOMMITTED".equalsIgnoreCase(defaultTransactionIsolation)) {
            return Connection.TRANSACTION_READ_UNCOMMITTED;
        }
        if ("REPEATABLE_READ".equalsIgnoreCase(defaultTransactionIsolation)) {
            return Connection.TRANSACTION_REPEATABLE_READ;
        }
        if ("SERIALIZABLE".equalsIgnoreCase(defaultTransactionIsolation)) {
            return Connection.TRANSACTION_SERIALIZABLE;
        }

        try {
            return Integer.parseInt(defaultTransactionIsolation);
        } catch (NumberFormatException nfex) {
            throw new IllegalStateException("Unrecognized 'defaultTransactionIsolation': "
                    + defaultTransactionIsolation);
        }
    }
 
开发者ID:bootique,项目名称:bootique-jdbc,代码行数:29,代码来源:TomcatManagedDataSourceFactory.java

示例3: setDefaultTransactionIsolationString

import org.apache.tomcat.jdbc.pool.DataSourceFactory; //导入依赖的package包/类
/**
 * Set the default transaction isolation level from a string value, based on the settings and values in java.sql.Connection
 * 
 * @param defaultTransactionIsolation
 */
public void setDefaultTransactionIsolationString(String defaultTransactionIsolation)
{
	if ((defaultTransactionIsolation == null) || (defaultTransactionIsolation.trim().length() == 0))
	{
		setDefaultTransactionIsolation(DataSourceFactory.UNKNOWN_TRANSACTIONISOLATION);
	}
	else if (defaultTransactionIsolation.trim().equalsIgnoreCase("TRANSACTION_NONE"))
	{
		setDefaultTransactionIsolation(Connection.TRANSACTION_NONE);
	}
	else if (defaultTransactionIsolation.trim().equalsIgnoreCase("TRANSACTION_READ_UNCOMMITTED"))
	{
		setDefaultTransactionIsolation(Connection.TRANSACTION_READ_UNCOMMITTED);
	}
	else if (defaultTransactionIsolation.trim().equalsIgnoreCase("TRANSACTION_READ_COMMITTED"))
	{
		setDefaultTransactionIsolation(Connection.TRANSACTION_READ_COMMITTED);
	}
	else if (defaultTransactionIsolation.trim().equalsIgnoreCase("TRANSACTION_REPEATABLE_READ"))
	{
		setDefaultTransactionIsolation(Connection.TRANSACTION_REPEATABLE_READ);
	}
	else if (defaultTransactionIsolation.trim().equalsIgnoreCase("TRANSACTION_SERIALIZABLE"))
	{
		setDefaultTransactionIsolation(Connection.TRANSACTION_SERIALIZABLE);
	}
	else
	{
		setDefaultTransactionIsolation(DataSourceFactory.UNKNOWN_TRANSACTIONISOLATION);
		log.warn("invalid transaction isolation level: " + defaultTransactionIsolation);
	}
}
 
开发者ID:sakaiproject,项目名称:sakai,代码行数:38,代码来源:SakaiBasicDataSource.java

示例4: DefaultProperties

import org.apache.tomcat.jdbc.pool.DataSourceFactory; //导入依赖的package包/类
public DefaultProperties() {
    setDbProperties(new Properties());

    //mysql
    //url = System.getProperty("url","jdbc:mysql://localhost:3306/mysql?autoReconnect=true");
    //driverClassName = System.getProperty("driverClassName","com.mysql.jdbc.Driver");

    //derby
    //url = System.getProperty("url","jdbc:derby:derbyDB;create=true");
    //driverClassName = System.getProperty("driverClassName","org.apache.derby.jdbc.EmbeddedDriver");

    setUrl(System.getProperty("url","jdbc:h2:~/.h2/test;QUERY_TIMEOUT=0;DB_CLOSE_ON_EXIT=FALSE"));
    setDriverClassName(System.getProperty("driverClassName","org.h2.Driver"));
    System.setProperty("h2.serverCachedObjects", "10000");

    setPassword(System.getProperty("password","password"));
    setUsername(System.getProperty("username","root"));

    setValidationQuery(System.getProperty("validationQuery","SELECT 1"));
    setDefaultAutoCommit(Boolean.TRUE);
    setDefaultReadOnly(Boolean.FALSE);
    setDefaultTransactionIsolation(DataSourceFactory.UNKNOWN_TRANSACTIONISOLATION);
    setConnectionProperties(null);
    setDefaultCatalog(null);
    setInitialSize(10);
    setMaxActive(100);
    setMaxIdle(getInitialSize());
    setMinIdle(getInitialSize());
    setMaxWait(10000);

    setTestOnBorrow(true);
    setTestOnReturn(false);
    setTestWhileIdle(true);
    setTimeBetweenEvictionRunsMillis(5000);
    setNumTestsPerEvictionRun(0);
    setMinEvictableIdleTimeMillis(1000);
    setRemoveAbandoned(true);
    setRemoveAbandonedTimeout(5000);
    setLogAbandoned(true);
    setValidationInterval(0); //always validate
    setInitSQL(null);
    setTestOnConnect(false);
    getDbProperties().setProperty("user",getUsername());
    getDbProperties().setProperty("password",getPassword());
}
 
开发者ID:liaokailin,项目名称:tomcat7,代码行数:46,代码来源:DefaultProperties.java

示例5: DefaultProperties

import org.apache.tomcat.jdbc.pool.DataSourceFactory; //导入依赖的package包/类
public DefaultProperties() {
    dbProperties = new Properties();
    
    //mysql
    //url = System.getProperty("url","jdbc:mysql://localhost:3306/mysql?autoReconnect=true"); 
    //driverClassName = System.getProperty("driverClassName","com.mysql.jdbc.Driver");
    
    //derby
    //url = System.getProperty("url","jdbc:derby:derbyDB;create=true");
    //driverClassName = System.getProperty("driverClassName","org.apache.derby.jdbc.EmbeddedDriver");
    
    url = System.getProperty("url","jdbc:h2:~/.h2/test;QUERY_TIMEOUT=0;DB_CLOSE_ON_EXIT=FALSE");
    driverClassName = System.getProperty("driverClassName","org.h2.Driver");
    System.setProperty("h2.serverCachedObjects", "10000");
    
    password = System.getProperty("password","password");
    username = System.getProperty("username","root");
    
    validationQuery = System.getProperty("validationQuery","SELECT 1");
    defaultAutoCommit = Boolean.TRUE;
    defaultReadOnly = Boolean.FALSE;
    defaultTransactionIsolation = DataSourceFactory.UNKNOWN_TRANSACTIONISOLATION;
    connectionProperties = null;
    defaultCatalog = null;
    initialSize = 10;
    maxActive = 100;
    maxIdle = initialSize;
    minIdle = initialSize;
    maxWait = 10000;
    
    testOnBorrow = true;
    testOnReturn = false;
    testWhileIdle = true;
    timeBetweenEvictionRunsMillis = 5000;
    numTestsPerEvictionRun = 0;
    minEvictableIdleTimeMillis = 1000;
    removeAbandoned = true;
    removeAbandonedTimeout = 5000;
    logAbandoned = true;
    validationInterval = 0; //always validate
    initSQL = null;
    testOnConnect = false;
    dbProperties.setProperty("user",username);
    dbProperties.setProperty("password",password);
}
 
开发者ID:WhiteBearSolutions,项目名称:WBSAirback,代码行数:46,代码来源:DefaultProperties.java

示例6: dataSource

import org.apache.tomcat.jdbc.pool.DataSourceFactory; //导入依赖的package包/类
@Bean
public DataSource dataSource() throws Exception {
  DataSourceFactory df = new DataSourceFactory();
  return df.createDataSource(PoolProperties.createFromEnvironment(this.env));
}
 
开发者ID:ferstl,项目名称:spring-jdbc-oracle,代码行数:6,代码来源:TomcatPoolDataSourceConfiguration.java


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