List of usage examples for org.apache.commons.dbcp2 BasicDataSource BasicDataSource
BasicDataSource
From source file:com.javacreed.examples.sql.DatabaseUtils.java
public static BasicDataSource createDataSource() { final BasicDataSource dataSource = new BasicDataSource(); dataSource.setDriverClassName("com.mysql.jdbc.Driver"); dataSource.setUrl("jdbc:mysql://localhost:3306/test_large_text"); dataSource.setUsername("root"); dataSource.setPassword("root"); return dataSource; }
From source file:moviemanager.backend.MovieManagerTest.java
private static DataSource prepareDataSource() throws SQLException { BasicDataSource ds = new BasicDataSource(); //we will use in memory database ds.setUrl(URL);/*from w ww . j a v a 2 s . com*/ return ds; }
From source file:cz.muni.pv168.dragonrental.backend.DragonRental.java
public static DataSource createMemoryDatabase() { BasicDataSource bds = new BasicDataSource(); //set JDBC driver and URL bds.setDriverClassName(EmbeddedDriver.class.getName()); bds.setUrl("jdbc:derby:memory:peopleDB;create=true"); //populate db with tables and data new ResourceDatabasePopulator(new ClassPathResource("schema-javadb.sql"), new ClassPathResource("test-data.sql")).execute(bds); return bds;//from w ww . j ava 2 s .c o m }
From source file:common.DBHelper.java
public static DataSource getDataSource() { Properties prop = new Properties(); try (InputStream input = DBHelper.class.getResourceAsStream("/config.PROPERTIES");) { prop.load(input);/*from w w w. j a v a 2 s. com*/ } catch (IOException e) { logger.error("error reading properties", e); } BasicDataSource ds = new BasicDataSource(); ds.setUrl(prop.getProperty("dbUrl")); ds.setDriverClassName("org.apache.derby.jdbc.ClientDriver"); ds.setUsername(prop.getProperty("dbUsername")); ds.setPassword(prop.getProperty("dbPassword")); return ds; }
From source file:moviemanager.backend.PersonManagerTest.java
private static DataSource prepareDataSource() throws SQLException { BasicDataSource ds = new BasicDataSource(); //we will use in memory database ds.setUrl(URL);/*from w w w . j ava 2 s.c om*/ ds.setUsername("administrator"); ds.setPassword("admin"); return ds; }
From source file:com.searchcode.app.config.DatabaseConfig.java
public Connection getConnection() throws SQLException { BasicDataSource ds = new BasicDataSource(); // pooling data source ds.setDriverClassName("org.hsqldb.jdbcDriver"); ds.setUsername("sa"); ds.setPassword(""); ds.setUrl("jdbc:hsqldb:file:searchcode;shutdown=true"); return ds.getConnection(); }
From source file:com.javacreed.secureproperties.utils.DbHelper.java
/** * * @return// www . j a v a 2s. c om * @throws SQLException */ public static DbHelper create() throws SQLException { final BasicDataSource dataSource = new BasicDataSource(); dataSource.setDriverClassName("org.h2.Driver"); dataSource.setUrl("jdbc:h2:./target/test"); dataSource.setUsername("sa"); dataSource.setPassword(""); final DbHelper helper = new DbHelper(dataSource); return helper; }
From source file:com.datasource.ParchemPool.java
private ParchemPool() throws IOException, SQLException, PropertyVetoException { ds = new BasicDataSource(); ds.setDriverClassName("com.microsoft.sqlserver.jdbc.SQLServerDriver"); ds.setUsername(""); ds.setPassword(""); ds.setUrl(""); }
From source file:com.datasource.ControlPanelPool.java
private ControlPanelPool() throws IOException, SQLException, PropertyVetoException { ds = new BasicDataSource(); ds.setDriverClassName("com.microsoft.sqlserver.jdbc.SQLServerDriver"); ds.setUsername(""); ds.setPassword(""); ds.setUrl(""); }
From source file:com.quick.config.JDBCConfig.java
@Bean @Override// www. j av a 2 s. c o m public DataSource dataSource() { BasicDataSource dataSource = new BasicDataSource(); dataSource.setDriverClassName(org.hsqldb.jdbcDriver.class.getName()); dataSource.setUsername("sa"); dataSource.setPassword(""); dataSource.setUrl("jdbc:hsqldb:mem:mydb"); return dataSource; }