當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。