本文整理汇总了Java中org.apache.tomcat.dbcp.dbcp.BasicDataSourceFactory类的典型用法代码示例。如果您正苦于以下问题:Java BasicDataSourceFactory类的具体用法?Java BasicDataSourceFactory怎么用?Java BasicDataSourceFactory使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
BasicDataSourceFactory类属于org.apache.tomcat.dbcp.dbcp包,在下文中一共展示了BasicDataSourceFactory类的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: setUpBeforeClass
import org.apache.tomcat.dbcp.dbcp.BasicDataSourceFactory; //导入依赖的package包/类
@BeforeClass
public static void setUpBeforeClass() throws Exception {
try {
Properties connectionProps = new Properties();
// TODO: Use context variables
connectionProps.put("username", "root");
connectionProps.put("password", "");
connectionProps.put("driverClassName", "com.mysql.jdbc.Driver");
connectionProps
.put("url",
"jdbc:mysql://localhost:3306/SE_Project_Test?autoCommit=false");
dataSource = BasicDataSourceFactory
.createDataSource(connectionProps);
con = dataSource.getConnection();
con.setAutoCommit(false);
} catch (NamingException e) {
Logger.getLogger(PatientDAO.class.getName()).log(Level.SEVERE,
null, e);
}
}
示例2: createDataSource
import org.apache.tomcat.dbcp.dbcp.BasicDataSourceFactory; //导入依赖的package包/类
/**
* Like JNDI, you can create DataSource
*
* @param prop properties
* @return
* @throws Exception
*
* @see {@link #destroyDataSource(DataSource)}
*/
public static DataSource createDataSource(final Properties prop) throws Exception {
return BasicDataSourceFactory.createDataSource(prop);
}