0

Here is sample code for the @beforeTest method:

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  
------------------------------------------------------  

I want to use Connection, but not sure what kind of Connection myBatis is using in the code below:

SqlSession session = sqlSessionFactory.openSession(Connection con);
4

1 回答 1

0

openSession方法需要java.sql.Connection. 您可能会发现本教程很有帮助。

于 2013-11-04T11:57:25.473 回答