本文整理汇总了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;
}
示例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;
}
示例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);
}
}
});
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}