郁闷了好久,在刚开始使用mybatis的时候,插入语句没有问题,但是有一个查询语句有问题,死活找不到原因,并且报以下错误,折腾了好几个小时,最终得知需要把Oracle数据库中的Long型的字段修改为Number,这样才可以正确的执行,汗!!!!
归结到底还是对Oracle数字段类型没有进入深入了解,以为Oracle中的long就是Java中的long,实际上如果是数字类型,最好 设置为number类型,Oracle中的long类型不要使用
long:可变字符序列,最大长度为2GB,用于不需要作字符串搜索的长串数据,如果要进行字符搜索就要用varchar2类型。long是一种比较老的数据类型,将来会主键被BLOB,CLOB,NCLOB等大的数据对象所取代
org.springframework.jdbc.UncategorizedSQLException: SqlSession operation; uncategorized SQLException for SQL []; SQL state [null]; error code [17027]; 流已被关闭; nested exception is java.sql.SQLException: 流已被关闭 at org.springframework.jdbc.support.SQLStateSQLExceptionTranslator.translate(SQLStateSQLExceptionTranslator.java:121) at org.springframework.jdbc.support.SQLErrorCodeSQLExceptionTranslator.translate(SQLErrorCodeSQLExceptionTranslator.java:322) at org.mybatis.spring.SqlSessionTemplate.wrapException(SqlSessionTemplate.java:364) at org.mybatis.spring.SqlSessionTemplate$7$1.doInSqlSession(SqlSessionTemplate.java:344) at org.mybatis.spring.SqlSessionTemplate.execute(SqlSessionTemplate.java:173) at org.mybatis.spring.SqlSessionTemplate.execute(SqlSessionTemplate.java:155) at org.mybatis.spring.SqlSessionTemplate$7.invoke(SqlSessionTemplate.java:339) at $Proxy9.queryById(Unknown Source) at com.sinosig.insurance.service.impl.DayAwardInfoServiceImp.queryById(DayAwardInfoServiceImp.java:18) at com.sinosig.insurance.test.TestMyBatis.Test(TestMyBatis.java:40) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) at java.lang.reflect.Method.invoke(Method.java:597) at org.springframework.test.context.junit4.SpringTestMethod.invoke(SpringTestMethod.java:198) at org.springframework.test.context.junit4.SpringMethodRoadie.runTestMethod(SpringMethodRoadie.java:274) at org.springframework.test.context.junit4.SpringMethodRoadie$2.run(SpringMethodRoadie.java:207) at org.springframework.test.context.junit4.SpringMethodRoadie.runBeforesThenTestThenAfters(SpringMethodRoadie.java:254) at org.springframework.test.context.junit4.SpringMethodRoadie.runWithRepetitions(SpringMethodRoadie.java:234) at org.springframework.test.context.junit4.SpringMethodRoadie.runTest(SpringMethodRoadie.java:204) at org.springframework.test.context.junit4.SpringMethodRoadie.run(SpringMethodRoadie.java:146) at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.invokeTestMethod(SpringJUnit4ClassRunner.java:151) at org.junit.internal.runners.JUnit4ClassRunner.runMethods(JUnit4ClassRunner.java:51) at org.junit.internal.runners.JUnit4ClassRunner$1.run(JUnit4ClassRunner.java:44) at org.junit.internal.runners.ClassRoadie.runUnprotected(ClassRoadie.java:27) at org.junit.internal.runners.ClassRoadie.runProtected(ClassRoadie.java:37) at org.junit.internal.runners.JUnit4ClassRunner.run(JUnit4ClassRunner.java:42) at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:46) at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:467) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:683) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:390) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:197) Caused by: java.sql.SQLException: 流已被关闭 at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:111) at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:145) at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:207) at oracle.jdbc.driver.LongAccessor.getBytes(LongAccessor.java:150) at oracle.jdbc.driver.LongAccessor.getString(LongAccessor.java:192) at oracle.jdbc.driver.T4CLongAccessor.getString(T4CLongAccessor.java:421) at oracle.jdbc.driver.CharCommonAccessor.getLong(CharCommonAccessor.java:234) at oracle.jdbc.driver.OracleResultSetImpl.getLong(OracleResultSetImpl.java:551) at oracle.jdbc.driver.OracleResultSet.getLong(OracleResultSet.java:1574) at org.apache.commons.dbcp.DelegatingResultSet.getLong(DelegatingResultSet.java:240) at org.apache.ibatis.type.LongTypeHandler.getNullableResult(LongTypeHandler.java:17) at org.apache.ibatis.type.BaseTypeHandler.getResult(BaseTypeHandler.java:29) at org.apache.ibatis.executor.resultset.FastResultSetHandler.applyAutomaticMappings(FastResultSetHandler.java:280) at org.apache.ibatis.executor.resultset.FastResultSetHandler.getRowValue(FastResultSetHandler.java:222) at org.apache.ibatis.executor.resultset.FastResultSetHandler.handleRowValues(FastResultSetHandler.java:173) at org.apache.ibatis.executor.resultset.FastResultSetHandler.handleResultSet(FastResultSetHandler.java:146) at org.apache.ibatis.executor.resultset.FastResultSetHandler.handleResultSets(FastResultSetHandler.java:112) at org.apache.ibatis.executor.statement.PreparedStatementHandler.query(PreparedStatementHandler.java:40) at org.apache.ibatis.executor.statement.RoutingStatementHandler.query(RoutingStatementHandler.java:55) at org.apache.ibatis.executor.SimpleExecutor.doQuery(SimpleExecutor.java:41) at org.apache.ibatis.executor.BaseExecutor.queryFromDatabase(BaseExecutor.java:238) at org.apache.ibatis.executor.BaseExecutor.query(BaseExecutor.java:112) at org.apache.ibatis.executor.CachingExecutor.query(CachingExecutor.java:72) at org.apache.ibatis.session.defaults.DefaultSqlSession.selectList(DefaultSqlSession.java:78) at org.apache.ibatis.session.defaults.DefaultSqlSession.selectList(DefaultSqlSession.java:72) at org.apache.ibatis.session.defaults.DefaultSqlSession.selectOne(DefaultSqlSession.java:38) at org.apache.ibatis.binding.MapperMethod.execute(MapperMethod.java:75) at org.apache.ibatis.binding.MapperProxy.invoke(MapperProxy.java:38) at $Proxy9.queryById(Unknown Source) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) at java.lang.reflect.Method.invoke(Method.java:597) at org.mybatis.spring.SqlSessionTemplate$7$1.doInSqlSession(SqlSessionTemplate.java:342) ... 29 more本文出自 “” 博客,请务必保留此出处