use of org.apache.commons.dbcp.BasicDataSource in project ma-core-public by infiniteautomation.
the class BasePooledProxy method initializeImpl.
@Override
protected void initializeImpl(String propertyPrefix) {
log.info("Initializing pooled connection manager");
dataSource = new BasicDataSource();
dataSource.setDriverClassName(getDriverClassName());
dataSource.setUrl(getUrl(propertyPrefix));
dataSource.setUsername(Common.envProps.getString(propertyPrefix + "db.username"));
dataSource.setPassword(getDatabasePassword(propertyPrefix));
dataSource.setMaxActive(Common.envProps.getInt(propertyPrefix + "db.pool.maxActive", 10));
dataSource.setMaxIdle(Common.envProps.getInt(propertyPrefix + "db.pool.maxIdle", 10));
dataSource.setValidationQuery("SELECT 1");
dataSource.setTestOnBorrow(true);
}
use of org.apache.commons.dbcp.BasicDataSource in project citrus-samples by christophd.
the class EndpointConfig method todoListDataSource.
@Bean(destroyMethod = "close")
public BasicDataSource todoListDataSource() {
BasicDataSource dataSource = new BasicDataSource();
dataSource.setDriverClassName("org.hsqldb.jdbcDriver");
dataSource.setUrl("jdbc:hsqldb:hsql://localhost/testdb");
dataSource.setUsername("sa");
dataSource.setPassword("");
dataSource.setInitialSize(1);
dataSource.setMaxActive(5);
dataSource.setMaxIdle(2);
return dataSource;
}
use of org.apache.commons.dbcp.BasicDataSource in project notes by KevinBlandy.
the class Demo method method1.
public static void method1() throws SQLException {
/**
* �������ӳض���,�����Ĵ����
* ���óز���
* �õ����Ӷ���
*/
// �������ӳض���
BasicDataSource dataSource = new BasicDataSource();
// �����Ĵ����
dataSource.setDriverClassName("com.mysql.jdbc.Driver");
dataSource.setUrl("jdbc:mysql://localhost:3306/demo");
dataSource.setUsername("root");
dataSource.setPassword("root");
// �������������
dataSource.setMaxActive(20);
// ������С�Ŀ�������
dataSource.setMinIdle(3);
// �������ȴ�ʱ��
dataSource.setMaxWait(1000);
// �õ����ӳض���
Connection conn = dataSource.getConnection();
System.out.println(conn.getClass().getName());
}
use of org.apache.commons.dbcp.BasicDataSource in project nutz by nutzam.
the class PsTest method main.
/**
* 测试新的Dao实现在postgresql下的表现
*/
public static void main(String[] args) throws Throwable {
BasicDataSource ds = new BasicDataSource();
ds.setDriverClassName("org.postgresql.Driver");
ds.setUsername("postgres");
ds.setPassword("123456");
ds.setUrl("jdbc:postgresql:test");
ds.setDefaultAutoCommit(false);
final NutDao dao = new NutDao(ds);
TableName.run(1, new Atom() {
public void run() {
Trans.exec(new Atom() {
public void run() {
dao.create(Country.class, true);
System.out.println("------------???");
dao.insert(Country.make("A"));
try {
System.out.println("---------------------");
dao.insert(Country.make("A"));
System.out.println("+++++++++++++++++++++++++++++++++++");
} catch (DaoException e) {
}
try {
dao.insert(Country.make("C"));
} catch (Throwable e) {
System.out.println("天啊,还是报错!!");
}
}
});
}
});
Connection conn = ds.getConnection();
conn.prepareStatement("insert into dao_country(name,detail) values('ABC','CC')").execute();
try {
conn.prepareStatement("insert into dao_country(name,detail) values('ABC','CC')").execute();
} catch (Exception e) {
}
conn.prepareStatement("insert into dao_country(name,detail) values('CC','CC')").execute();
System.out.println("竟然能通过??!!");
conn.commit();
}
use of org.apache.commons.dbcp.BasicDataSource in project qi4j-sdk by Qi4j.
the class ExternalDataSourceTest method assemble.
@Override
public void assemble(ModuleAssembly module) throws AssemblyException {
BasicDataSource externalDataSource = new BasicDataSource();
externalDataSource.setDriverClassName("org.apache.derby.jdbc.EmbeddedDriver");
externalDataSource.setUrl("jdbc:derby:memory:testdbexternal;create=true");
// START SNIPPET: assembly
new ExternalDataSourceAssembler(externalDataSource).visibleIn(Visibility.module).identifiedBy("datasource-external-id").withCircuitBreaker(DataSources.newDataSourceCircuitBreaker()).assemble(module);
// END SNIPPET: assembly
}
Aggregations