ibatis插入date类型报错
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
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(6)
ok
java.sql.Date.valueOf(dd) 这句话转化成了Date类型了啊,传进的是date类型
回复
数据库字段是什么类型的?
回复
Date
回复
找到原因啦!xml中的sql最后多了“;”!!!
你的数据库字段类型如果是date类型的,那么,你就要传java的Date进去,不要自作主张的再去传递一个字符串进去。