下面是@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);发布于 2013-11-04 19:57:25
openSession方法需要java.sql.Connection的实例。您可能会发现this tutorial很有帮助。
https://stackoverflow.com/questions/19693898
复制相似问题