ibatis插入date类型报错

键盘上的魔术师 发布于 2015/03/03 12:30
阅读 1K+
收藏 0

action类:

java.util.Date d = new java.util.Date();

SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
String dd = sdf.format(d); 

EciqFixedPermission efp = new EciqFixedPermission();

efp.setIN_TIME(java.sql.Date.valueOf(dd));


xml:

insert into eciq_fixed_permission(DEPT_ID,TABLE_ID,IN_NAM,IN_TIME,UP_MAN,UP_TIME) 
                                   values(#DEPT_ID#,#TABLE_ID#,#IN_NAM#,#IN_TIME#,#UP_MAN#,#UP_TIME#);


控制台:

015-03-03 12:20:19 [com.ibatis.common.jdbc.SimpleDataSource]-[DEBUG] Created connection 25294139.
 2015-03-03 12:20:19 [java.sql.Connection]-[DEBUG] {conn-100043} Connection
 2015-03-03 12:20:19 [java.sql.Connection]-[DEBUG] {conn-100043} Preparing Statement:          insert into eciq_fixed_permission(DEPT_ID,TABLE_ID,IN_NAM,IN_TIME,UP_MAN,UP_TIME)                                      values(?,?,?,to_date(?,'yyyy-mm-dd'),?,to_date(?,'yyyy-mm-dd'));     
 2015-03-03 12:20:19 [java.sql.PreparedStatement]-[DEBUG] {pstm-100044} Executing Statement:          insert into eciq_fixed_permission(DEPT_ID,TABLE_ID,IN_NAM,IN_TIME,UP_MAN,UP_TIME)                                      values(?,?,?,to_date(?,'yyyy-mm-dd'),?,to_date(?,'yyyy-mm-dd'));     
 2015-03-03 12:20:19 [java.sql.PreparedStatement]-[DEBUG] {pstm-100044} Executing Statement:          insert into eciq_fixed_permission(DEPT_ID,TABLE_ID,IN_NAM,IN_TIME,UP_MAN,UP_TIME)                                      values(?,?,?,to_date(?,'yyyy-mm-dd'),?,to_date(?,'yyyy-mm-dd'));     
 2015-03-03 12:20:19 [java.sql.PreparedStatement]-[DEBUG] {pstm-100044} Parameters: [31000100, 08, 397, 2015-03-03, , 2015-03-03]
 2015-03-03 12:20:19 [java.sql.PreparedStatement]-[DEBUG] {pstm-100044} Parameters: [31000100, 08, 397, 2015-03-03, , 2015-03-03]
 2015-03-03 12:20:19 [java.sql.PreparedStatement]-[DEBUG] {pstm-100044} Types: [java.lang.String, java.lang.String, java.lang.String, java.sql.Date, java.lang.String, java.sql.Date]
 2015-03-03 12:20:19 [java.sql.PreparedStatement]-[DEBUG] {pstm-100044} Types: [java.lang.String, java.lang.String, java.lang.String, java.sql.Date, java.lang.String, java.sql.Date]
 2015-03-03 12:20:19 [com.ibatis.common.jdbc.SimpleDataSource]-[DEBUG] Returned connection 25294139 to pool.
 com.ibatis.common.jdbc.exception.NestedSQLException:   
--- The error occurred in com/sinosoft/dssnew/config/ibatisconfig/fixedPermission.xml.  
--- The error occurred while applying a parameter map.  
--- Check the insertFixedPermission-InlineParameterMap.  
--- Check the statement (update failed).  
--- Cause: java.sql.SQLException: ORA-00911: 无效字符


at com.ibatis.sqlmap.engine.mapping.statement.GeneralStatement.executeUpdate(GeneralStatement.java:91)
at com.ibatis.sqlmap.engine.impl.SqlMapExecutorDelegate.insert(SqlMapExecutorDelegate.java:447)
at com.ibatis.sqlmap.engine.impl.SqlMapSessionImpl.insert(SqlMapSessionImpl.java:82)
at com.ibatis.sqlmap.engine.impl.SqlMapClientImpl.insert(SqlMapClientImpl.java:59)
at com.sinosoft.dss.collect.dao.setMenu.impl.FixedPermissionDaoImpl.insertFixedPermission(FixedPermissionDaoImpl.java:26)
at com.sinosoft.dss.collect.action.setMenu.FixedPermissionAction.insertFixedPermission(FixedPermissionAction.java:118)
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.apache.struts.actions.DispatchAction.dispatchMethod(DispatchAction.java:270)
at org.apache.struts.actions.DispatchAction.execute(DispatchAction.java:187)
at org.apache.struts.action.RequestProcessor.processActionPerform(RequestProcessor.java:431)
at org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:236)
at org.apache.struts.action.ActionServlet.process(ActionServlet.java:1196)
at org.apache.struts.action.ActionServlet.doGet(ActionServlet.java:414)
at com.sinosoft.plugin.SinoEpActionServlet.doPost(SinoEpActionServlet.java:63)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:643)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:723)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at com.sinosoft.util.tool.SetCharacterEncodingFilter.doFilter(SetCharacterEncodingFilter.java:55)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at com.sinosoft.authorization.module.system.login.filter.RightRoleFilter.doFilte

加载中
0
sxgkwei
sxgkwei
你的数据库字段类型如果是date类型的,那么,你就要传java的Date进去,不要自作主张的再去传递一个字符串进去。
键盘上的魔术师
键盘上的魔术师
回复 @sxgkwei : 找到原因啦!xml中的sql最后多了“;”!!!
键盘上的魔术师
键盘上的魔术师
回复 @sxgkwei :Date
sxgkwei
sxgkwei
回复 @键盘上的魔术师 : 数据库字段是什么类型的?
键盘上的魔术师
键盘上的魔术师
java.sql.Date.valueOf(dd) 这句话转化成了Date类型了啊,传进的是date类型
0
堕落的七彩琉璃
堕落的七彩琉璃
ibatis 你数据库是Date类型 你用# 就会把传入的数据当作字符串 就算数据是Date类型的 你尝试#IN_TIME:DATE#
OSCHINA
登录后可查看更多优质内容
返回顶部
顶部