mybatis 查询一直出异常 求助 提示下标越界

zx362168897 2013-07-12 03:03:29
1
org.springframework.jdbc.UncategorizedSQLException:
### Error querying database. Cause: java.sql.SQLException: An SQLException was provoked by the following failure: java.lang.StringIndexOutOfBoundsException: String index out of range: 10
### The error may exist in com/sec/bean/mapper/wap_transactionMapper.xml
### The error may involve com.sec.bean.5008custom-Inline
### The error occurred while setting parameters
### SQL: select count(custom_time) as custom_user,leagueid,miscid,service_id from tcom5008_mms_platform.wap_transaction_detail where custom_time!='0000-00-00 00:00:00' and left(custom_time,10)=? GROUP BY leagueid,service_id,miscid
### Cause: java.sql.SQLException: An SQLException was provoked by the following failure: java.lang.StringIndexOutOfBoundsException: String index out of range: 10
; uncategorized SQLException for SQL []; SQL state [null]; error code [0]; An SQLException was provoked by the following failure: java.lang.StringIndexOutOfBoundsException: String index out of range: 10; nested exception is java.sql.SQLException: An SQLException was provoked by the following failure: java.lang.StringIndexOutOfBoundsException: String index out of range: 10
at org.springframework.jdbc.support.AbstractFallbackSQLExceptionTranslator.translate(AbstractFallbackSQLExceptionTranslator.java:83)
at org.springframework.jdbc.support.AbstractFallbackSQLExceptionTranslator.translate(AbstractFallbackSQLExceptionTranslator.java:80)
at org.springframework.jdbc.support.AbstractFallbackSQLExceptionTranslator.translate(AbstractFallbackSQLExceptionTranslator.java:80)
at org.mybatis.spring.MyBatisExceptionTranslator.translateExceptionIfPossible(MyBatisExceptionTranslator.java:71)

at org.mybatis.spring.SqlSessionTemplate$SqlSessionInterceptor.invoke(SqlSessionTemplate.java:365)
at $Proxy5.selectList(Unknown Source)
at org.mybatis.spring.SqlSessionTemplate.selectList(SqlSessionTemplate.java:195)
at com.sec.dao.impl.BaseDaoImpl.queryForList(BaseDaoImpl.java:77)
at com.sec.quartz.job.WapTransaction.execute(WapTransaction.java:23)
at org.quartz.core.JobRunShell.run(JobRunShell.java:213)
at org.quartz.simpl.SimpleThreadPool$WorkerThread.run(SimpleThreadPool.java:557)
Caused by: java.sql.SQLException: An SQLException was provoked by the following failure: java.lang.StringIndexOutOfBoundsException: String index out of range: 10
at com.mchange.v2.sql.SqlUtils.toSQLException(SqlUtils.java:106)
at com.mchange.v2.sql.SqlUtils.toSQLException(SqlUtils.java:65)
at com.mchange.v2.sql.SqlUtils.toSQLException(SqlUtils.java:62)
at com.mchange.v2.c3p0.impl.NewPooledConnection.handleThrowable(NewPooledConnection.java:432)
at com.mchange.v2.c3p0.impl.NewProxyPreparedStatement.setString(NewProxyPreparedStatement.java:977)
at org.apache.ibatis.type.StringTypeHandler.setNonNullParameter(StringTypeHandler.java:28)
at org.apache.ibatis.type.StringTypeHandler.setNonNullParameter(StringTypeHandler.java:23)
at org.apache.ibatis.type.BaseTypeHandler.setParameter(BaseTypeHandler.java:46)
at org.apache.ibatis.type.UnknownTypeHandler.setNonNullParameter(UnknownTypeHandler.java:37)
at org.apache.ibatis.type.BaseTypeHandler.setParameter(BaseTypeHandler.java:46)
at org.apache.ibatis.executor.parameter.DefaultParameterHandler.setParameters(DefaultParameterHandler.java:91)
at org.apache.ibatis.executor.statement.PreparedStatementHandler.parameterize(PreparedStatementHandler.java:77)
at org.apache.ibatis.executor.statement.RoutingStatementHandler.parameterize(RoutingStatementHandler.java:58)
at org.apache.ibatis.executor.SimpleExecutor.prepareStatement(SimpleExecutor.java:71)
at org.apache.ibatis.executor.SimpleExecutor.doQuery(SimpleExecutor.java:56)
at org.apache.ibatis.executor.BaseExecutor.queryFromDatabase(BaseExecutor.java:267)
at org.apache.ibatis.executor.BaseExecutor.query(BaseExecutor.java:141)
at org.apache.ibatis.executor.CachingExecutor.query(CachingExecutor.java:105)
at org.apache.ibatis.executor.CachingExecutor.query(CachingExecutor.java:81)
at org.apache.ibatis.session.defaults.DefaultSqlSession.selectList(DefaultSqlSession.java:101)
at org.apache.ibatis.session.defaults.DefaultSqlSession.selectList(DefaultSqlSession.java:95)

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$SqlSessionInterceptor.invoke(SqlSessionTemplate.java:355)
... 6 more
Caused by: java.lang.StringIndexOutOfBoundsException: String index out of range: 10
at java.lang.String.charAt(String.java:687)
at com.mysql.jdbc.StringUtils.escapeEasternUnicodeByteStream(StringUtils.java:231)
at com.mysql.jdbc.StringUtils.getBytesWrapped(StringUtils.java:575)
at com.mysql.jdbc.PreparedStatement.setString(PreparedStatement.java:4131)
at com.mchange.v2.c3p0.impl.NewProxyPreparedStatement.setString(NewProxyPreparedStatement.java:963)
... 27 more




sql:
<select id="5008pause" parameterType="map" resultType="map">
<![CDATA[
select count(pause_time) as custom_user,leagueid,miscid,service_id from test where pause_time!='0000-00-00 00:00:00' and left(pause_time,10)=#{time} GROUP BY leagueid,service_id,miscid
]]>
</select>


代码:
String time="2013-06-30";
System.out.println(1);
Map param=new HashMap();
param.put("time", time);
List list=baseDao.queryForList("5008custom",param);
System.out.println(2);
System.out.println(list.size());
System.out.println(list.get(0).toString());
...全文
1032 4 打赏 收藏 转发到动态 举报
写回复
用AI写文章
4 条回复
切换为时间正序
请发表友善的回复…
发表回复
tony4geek 2013-07-12
  • 打赏
  • 举报
回复
你 试试下 这个有没有问题
left(pause_time,10)
lzh_me 2013-07-12
  • 打赏
  • 举报
回复
left(pause_time,10) 是不是 下标越界了,跟踪下代码看看吧
zx362168897 2013-07-12
  • 打赏
  • 举报
回复
引用 1 楼 aihu_2013 的回复:
custom_time的长度是多少
datetime
aihu_2013 2013-07-12
  • 打赏
  • 举报
回复
custom_time的长度是多少

67,513

社区成员

发帖
与我相关
我的任务
社区描述
J2EE只是Java企业应用。我们需要一个跨J2SE/WEB/EJB的微容器,保护我们的业务核心组件(中间件),以延续它的生命力,而不是依赖J2SE/J2EE版本。
社区管理员
  • Java EE
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧