use of javax.sql.DataSource in project druid by alibaba.
the class SqlMapClientWrapperTest method setUp.
protected void setUp() throws Exception {
context = new ClassPathXmlApplicationContext("com/alibaba/druid/pool/ibatis/spring-config-ibatis-1.xml");
DataSource dataSource = (DataSource) context.getBean("dataSource");
{
Connection conn = dataSource.getConnection();
Statement stmt = conn.createStatement();
stmt.execute("CREATE TABLE sequence_seed (value INTEGER, name VARCHAR(50))");
stmt.close();
conn.close();
}
{
Connection conn = dataSource.getConnection();
Statement stmt = conn.createStatement();
stmt.execute("CREATE TABLE t_User (id BIGINT, name VARCHAR(50))");
stmt.close();
conn.close();
}
}
use of javax.sql.DataSource in project java-design-patterns by iluwatar.
the class AppConfig method dataSource.
/**
* Creation of H2 db
*
* @return A new Instance of DataSource
*/
@Bean(destroyMethod = "close")
public DataSource dataSource() {
BasicDataSource basicDataSource = new BasicDataSource();
basicDataSource.setDriverClassName("org.h2.Driver");
basicDataSource.setUrl("jdbc:h2:~/databases/person");
basicDataSource.setUsername("sa");
basicDataSource.setPassword("sa");
return (DataSource) basicDataSource;
}
use of javax.sql.DataSource in project eweb4j-framework by laiweiwei.
the class DAOFactory method getSearchDAO.
/**
* 创建SearchDAOImpl实例
*
* @param dsName
* 数据库配置信息Bean的名字,默认下在eweb4j-dbInfo-config.xml文件中<name></name>
* 找到这个值
* @return
*/
public static SearchDAO getSearchDAO(String dsName) {
DataSource ds = DataSourceWrapCache.get(dsName);
DBInfoConfigBean dcb = DBInfoConfigBeanCache.get(dsName);
return new SearchDAOImpl(ds, dcb.getDataBaseType());
}
use of javax.sql.DataSource in project eweb4j-framework by laiweiwei.
the class DAOFactory method getSelectDAO.
/**
* 创建SelectDAOImpl实例
*
* @param dsName
* 数据库配置信息Bean的名字,默认下在eweb4j-dbInfo-config.xml文件中<name></name>
* 找到这个值
* @return
*/
public static SelectDAO getSelectDAO(String dsName) {
DataSource ds = DataSourceWrapCache.get(dsName);
DBInfoConfigBean dcb = DBInfoConfigBeanCache.get(dsName);
return new SelectDAOImpl(ds, dcb.getDataBaseType());
}
use of javax.sql.DataSource in project eweb4j-framework by laiweiwei.
the class DAOFactory method getSearchDAO.
public static SearchDAO getSearchDAO() {
DataSource ds = DataSourceWrapCache.get();
DBInfoConfigBean dcb = DBInfoConfigBeanCache.get();
return new SearchDAOImpl(ds, dcb.getDataBaseType());
}
Aggregations