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


Java BasicDataSource.setDriver方法代码示例

本文整理汇总了Java中org.apache.commons.dbcp2.BasicDataSource.setDriver方法的典型用法代码示例。如果您正苦于以下问题:Java BasicDataSource.setDriver方法的具体用法?Java BasicDataSource.setDriver怎么用?Java BasicDataSource.setDriver使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.apache.commons.dbcp2.BasicDataSource的用法示例。


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

示例1: dataSource

import org.apache.commons.dbcp2.BasicDataSource; //导入方法依赖的package包/类
/**
 * The following bean configures the database connection. The 'url' property value of "jdbc:derby:directory:jpaserver_derby_files;create=true" indicates that the server should save resources in a
 * directory called "jpaserver_derby_files".
 * 
 * A URL to a remote database could also be placed here, along with login credentials and other properties supported by BasicDataSource.
 */
@Bean(destroyMethod = "close")
public DataSource dataSource() {
	BasicDataSource retVal = new BasicDataSource();
	/*
	retVal.setDriver(new org.apache.derby.jdbc.EmbeddedDriver());
	retVal.setUrl("jdbc:derby:directory:target/jpaserver_derby_files;create=true");
	retVal.setUsername("");
	retVal.setPassword("");
	* */
	 
	
	try
	{
		retVal.setDriver(new com.mysql.jdbc.Driver());
	}
	catch (Exception exc)
	{
		exc.printStackTrace();
	}
	retVal.setUrl("jdbc:mysql://localhost:3306/dhis2_fhir");
	retVal.setUsername("root");
	retVal.setPassword("");
	return retVal;
}
 
开发者ID:gerard-bisama,项目名称:DHIS2-fhir-lab-app,代码行数:31,代码来源:FhirServerConfigDstu3.java

示例2: dataSource

import org.apache.commons.dbcp2.BasicDataSource; //导入方法依赖的package包/类
/**
 * The following bean configures the database connection. The 'url' property value of "jdbc:derby:directory:jpaserver_derby_files;create=true" indicates that the server should save resources in a
 * directory called "jpaserver_derby_files".
 * 
 * A URL to a remote database could also be placed here, along with login credentials and other properties supported by BasicDataSource.
 */
@Bean(destroyMethod = "close")
public DataSource dataSource() {
	BasicDataSource retVal = new BasicDataSource();
	/*
	retVal.setDriver(new org.apache.derby.jdbc.EmbeddedDriver());
	retVal.setUrl("jdbc:derby:directory:target/jpaserver_derby_files;create=true");
	retVal.setUsername("");
	retVal.setPassword("");
	*/
	try
	{
		//retVal.setDriver(new com.mysql.jdbc.Driver());
		retVal.setDriver(new org.postgresql.Driver());
	}
	catch (Exception exc)
	{
		exc.printStackTrace();
	}
	//retVal.setUrl("jdbc:mysql://localhost:3306/dhis2_fhir");
	retVal.setUrl("jdbc:postgresql://localhost:5432/dhis2_fhir");
	retVal.setUsername("fhir");
	retVal.setPassword("xxxxxxx");
	
	return retVal;
}
 
开发者ID:gerard-bisama,项目名称:DHIS2-fhir-lab-app,代码行数:32,代码来源:FhirServerConfig.java

示例3: DBManager

import org.apache.commons.dbcp2.BasicDataSource; //导入方法依赖的package包/类
public DBManager() {
    ds = new BasicDataSource();
    ds.setDriver(new EmbeddedDriver());
    ds.setUrl(Constants.JDBC);
    
    flyway = new Flyway();
    flyway.setDataSource(ds);
    //flyway.clean();
    flyway.migrate();

    // just to be sure, try to close
    Runtime.getRuntime().addShutdownHook(new Thread() {
        @Override
        public void run() {
            try {
                LOG.info("Closing DB connection...");
                ds.close();
                LOG.info("DB closed");
            } catch (SQLException ex) {
                LOG.error("Error closing DB cconnection", ex);
            }
        }
    });
}
 
开发者ID:dainesch,项目名称:HueSense,代码行数:25,代码来源:DBManager.java

示例4: dataSource

import org.apache.commons.dbcp2.BasicDataSource; //导入方法依赖的package包/类
/**
 * A URL to a remote database could also be placed here, along with login credentials and other properties supported by BasicDataSource.
 */
@Bean(destroyMethod = "close")
public DataSource dataSource() throws SQLException {
    BasicDataSource retVal = new BasicDataSource();
    retVal.setDriver(new com.intersys.jdbc.CacheDriver());
    retVal.setUrl("jdbc:Cache://127.0.0.1:1972/FHIR/");
    retVal.setUsername("_SYSTEM");
    retVal.setPassword("SYS");
    return retVal;
}
 
开发者ID:daimor,项目名称:isc-hapi-fhir-jpaserver,代码行数:13,代码来源:FhirServerConfig.java

示例5: dataSource

import org.apache.commons.dbcp2.BasicDataSource; //导入方法依赖的package包/类
@Bean(destroyMethod = "close")
public DataSource dataSource() {
    BasicDataSource retVal = new BasicDataSource();
    retVal.setDriver(new org.apache.derby.jdbc.EmbeddedDriver());
    retVal.setUrl("jdbc:derby:directory:target/jpaserver_derby_files;create=true");
    retVal.setUsername("");
    retVal.setPassword("");
    return retVal;
}
 
开发者ID:DBCG,项目名称:cqf-ruler,代码行数:10,代码来源:FhirServerConfigDstu3.java

示例6: dataSource

import org.apache.commons.dbcp2.BasicDataSource; //导入方法依赖的package包/类
/**
 * The following bean configures the database connection. The 'url' property value of "jdbc:derby:directory:jpaserver_derby_files;create=true" indicates that the server should save resources in a
 * directory called "jpaserver_derby_files".
 * 
 * A URL to a remote database could also be placed here, along with login credentials and other properties supported by BasicDataSource.
 */
@Bean(destroyMethod = "close")
public DataSource dataSource() {
	BasicDataSource retVal = new BasicDataSource();
	retVal.setDriver(new org.apache.derby.jdbc.EmbeddedDriver());
	retVal.setUrl("jdbc:derby:directory:target/jpaserver_derby_files;create=true");
	retVal.setUsername("");
	retVal.setPassword("");
	return retVal;
}
 
开发者ID:furore-fhir,项目名称:fhirstarters,代码行数:16,代码来源:FhirServerConfigDstu3.java

示例7: dataSource

import org.apache.commons.dbcp2.BasicDataSource; //导入方法依赖的package包/类
@Bean(name = "myPersistenceDataSourceDstu1", destroyMethod = "close")
public DataSource dataSource() {
	BasicDataSource retVal = new BasicDataSource();
	if (CommonConfig.isLocalTestMode()) {
		retVal.setUrl("jdbc:derby:memory:fhirtest_dstu2;create=true");
	} else {
		retVal.setDriver(new org.postgresql.Driver());
		retVal.setUrl("jdbc:postgresql://localhost/fhirtest_dstu2");
	}
	retVal.setUsername(myDbUsername);
	retVal.setPassword(myDbPassword);
	return retVal;
}
 
开发者ID:jamesagnew,项目名称:hapi-fhir,代码行数:14,代码来源:TestDstu2Config.java

示例8: dataSource

import org.apache.commons.dbcp2.BasicDataSource; //导入方法依赖的package包/类
@Bean(name = "myPersistenceDataSourceR4", destroyMethod = "close")
public DataSource dataSource() {
	BasicDataSource retVal = new BasicDataSource();
	if (CommonConfig.isLocalTestMode()) {
		retVal.setUrl("jdbc:derby:memory:fhirtest_r4;create=true");
	} else {
		retVal.setDriver(new org.postgresql.Driver());
		retVal.setUrl("jdbc:postgresql://localhost/fhirtest_r4");
	}
	retVal.setUsername(myDbUsername);
	retVal.setPassword(myDbPassword);
	return retVal;
}
 
开发者ID:jamesagnew,项目名称:hapi-fhir,代码行数:14,代码来源:TestR4Config.java

示例9: dataSource

import org.apache.commons.dbcp2.BasicDataSource; //导入方法依赖的package包/类
@Bean(name = "myPersistenceDataSourceDstu3", destroyMethod = "close")
public DataSource dataSource() {
	BasicDataSource retVal = new BasicDataSource();
	if (CommonConfig.isLocalTestMode()) {
		retVal.setUrl("jdbc:derby:memory:fhirtest_dstu3;create=true");
	} else {
		retVal.setDriver(new org.postgresql.Driver());
		retVal.setUrl("jdbc:postgresql://localhost/fhirtest_dstu3");
	}
	retVal.setUsername(myDbUsername);
	retVal.setPassword(myDbPassword);
	return retVal;
}
 
开发者ID:jamesagnew,项目名称:hapi-fhir,代码行数:14,代码来源:TestDstu3Config.java

示例10: dataSource

import org.apache.commons.dbcp2.BasicDataSource; //导入方法依赖的package包/类
@Bean()
public DataSource dataSource() {
	BasicDataSource retVal = new BasicDataSource();
	retVal.setDriver(new org.apache.derby.jdbc.EmbeddedDriver());
	retVal.setUrl("jdbc:derby:memory:myUnitTestDBDstu2;create=true");
	retVal.setUsername("");
	retVal.setPassword("");
	return retVal;
}
 
开发者ID:jamesagnew,项目名称:hapi-fhir,代码行数:10,代码来源:TestDstu2Config.java

示例11: dataSource

import org.apache.commons.dbcp2.BasicDataSource; //导入方法依赖的package包/类
/**
 * The following bean configures the database connection. The 'url' property value of "jdbc:derby:directory:jpaserver_derby_files;create=true" indicates that the server should save resources in a
 * directory called "jpaserver_derby_files".
 * 
 * A URL to a remote database could also be placed here, along with login credentials and other properties supported by BasicDataSource.
 */
@Bean(destroyMethod = "close")
public DataSource dataSource() {
	BasicDataSource retVal = new BasicDataSource();
	retVal.setDriver(new org.postgresql.Driver());
	retVal.setUrl("jdbc:postgresql://localhost:5432/hapi");
	retVal.setUsername("hapi");
	retVal.setPassword("mysecretpassword");
	return retVal;
}
 
开发者ID:jamesagnew,项目名称:hapi-fhir,代码行数:16,代码来源:FhirServerConfig.java


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