El_cuervo
El_cuervo
2017-10-23 04:14

求助java学习过程中使用mybatis时遇到异常报错PersistenceException

  • exception
  • java
  • mybatis
  • 数据库
  • 异常

异常错误信息是

 Exception in thread "main" org.apache.ibatis.exceptions.PersistenceException: 
### Error querying database.  Cause: java.lang.NullPointerException
### The error may exist in com/briup/estore/dao/CustomerMapper.xml
### The error may involve com.briup.estore.dao.ICustomerDao.findByName
### The error occurred while executing a query
### Cause: java.lang.NullPointerException
    at org.apache.ibatis.exceptions.ExceptionFactory.wrapException(ExceptionFactory.java:30)
    at org.apache.ibatis.session.defaults.DefaultSqlSession.selectList(DefaultSqlSession.java:122)
    at org.apache.ibatis.session.defaults.DefaultSqlSession.selectList(DefaultSqlSession.java:113)
    at org.apache.ibatis.session.defaults.DefaultSqlSession.selectOne(DefaultSqlSession.java:73)
    at org.apache.ibatis.binding.MapperMethod.execute(MapperMethod.java:69)
    at org.apache.ibatis.binding.MapperProxy.invoke(MapperProxy.java:53)
    at com.sun.proxy.$Proxy0.findByName(Unknown Source)
    at com.briup.estore.service.impl.Test.main(Test.java:21)
Caused by: java.lang.NullPointerException
    at java.lang.String.<init>(Unknown Source)
    at oracle.sql.CharacterSet.AL32UTF8ToString(CharacterSet.java:1518)
    at oracle.jdbc.driver.DBConversion.CharBytesToString(DBConversion.java:610)
    at oracle.jdbc.driver.DBConversion.CharBytesToString(DBConversion.java:555)
    at oracle.jdbc.driver.T4CTTIoauthenticate.receiveOauth(T4CTTIoauthenticate.java:822)
    at oracle.jdbc.driver.T4CConnection.logon(T4CConnection.java:362)
    at oracle.jdbc.driver.PhysicalConnection.<init>(PhysicalConnection.java:441)
    at oracle.jdbc.driver.T4CConnection.<init>(T4CConnection.java:165)
    at oracle.jdbc.driver.T4CDriverExtension.getConnection(T4CDriverExtension.java:35)
    at oracle.jdbc.driver.OracleDriver.connect(OracleDriver.java:801)
    at java.sql.DriverManager.getConnection(Unknown Source)
    at java.sql.DriverManager.getConnection(Unknown Source)
    at org.apache.ibatis.datasource.unpooled.UnpooledDataSource.doGetConnection(UnpooledDataSource.java:201)
    at org.apache.ibatis.datasource.unpooled.UnpooledDataSource.doGetConnection(UnpooledDataSource.java:196)
    at org.apache.ibatis.datasource.unpooled.UnpooledDataSource.getConnection(UnpooledDataSource.java:93)
    at org.apache.ibatis.datasource.pooled.PooledDataSource.popConnection(PooledDataSource.java:385)
    at org.apache.ibatis.datasource.pooled.PooledDataSource.getConnection(PooledDataSource.java:89)
    at org.apache.ibatis.transaction.jdbc.JdbcTransaction.openConnection(JdbcTransaction.java:140)
    at org.apache.ibatis.transaction.jdbc.JdbcTransaction.getConnection(JdbcTransaction.java:62)
    at org.apache.ibatis.executor.BaseExecutor.getConnection(BaseExecutor.java:315)
    at org.apache.ibatis.executor.SimpleExecutor.prepareStatement(SimpleExecutor.java:75)
    at org.apache.ibatis.executor.SimpleExecutor.doQuery(SimpleExecutor.java:61)
    at org.apache.ibatis.executor.BaseExecutor.queryFromDatabase(BaseExecutor.java:303)
    at org.apache.ibatis.executor.BaseExecutor.query(BaseExecutor.java:154)
    at org.apache.ibatis.executor.CachingExecutor.query(CachingExecutor.java:102)
    at org.apache.ibatis.executor.CachingExecutor.query(CachingExecutor.java:82)
    at org.apache.ibatis.session.defaults.DefaultSqlSession.selectList(DefaultSqlSession.java:120)
    ... 6 more

我使用的mybatis-config.xml和mapper.xml中的代码都没有问题,我把原代码打包都放入他人电脑中运行都能成功,而我的不行,会报上述异常,数据库用的是Oracle 10g ,编译代码的是eclipse 4.7,Oracle使用cmd命令可以使用,但是就是用mybatis的不行,有没有大佬知道这种情况的,求帮助

  • 点赞
  • 回答
  • 收藏
  • 复制链接分享

4条回答