本文整理汇总了Java中org.apache.tomcat.dbcp.dbcp.BasicDataSourceFactory.createDataSource方法的典型用法代码示例。如果您正苦于以下问题:Java BasicDataSourceFactory.createDataSource方法的具体用法?Java BasicDataSourceFactory.createDataSource怎么用?Java BasicDataSourceFactory.createDataSource使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.tomcat.dbcp.dbcp.BasicDataSourceFactory
的用法示例。
在下文中一共展示了BasicDataSourceFactory.createDataSource方法的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);
}