myBatis无法openSession,selenium整合和myBatis

时间:2013-10-30 21:12:48

标签: java testing selenium integration mybatis

以下是@beforeTest方法的示例代码:

String resource = "mybatis-config.xml";
InputStream inputStream = Resources.getResourceAsStream(resource);
SqlSessionFactory sqlSessionFactory = new ( SqlSessionFactoryBuilder().build(inputStream);
SqlSession session = sqlSessionFactory.openSession();  
here couldnot open the  connection    

and the output testing under testNG is:
FAILED CONFIGURATION: @BeforeTest setupPermission
org.apache.ibatis.exceptions.PersistenceException:  
Error opening session.  Cause: java.lang.NullPointerException  
Cause: java.lang.NullPointerException  
------------------------------------------------------  

我想使用Connection,但不确定myBatis在下面的代码中使用的是什么类型的连接:

SqlSession session = sqlSessionFactory.openSession(Connection con);

1 个答案:

答案 0 :(得分:0)

openSession方法需要java.sql.Connection的实例。您可能会发现this tutorial有帮助。