技术CTO-关注编程入门知识,提供编程入门教程

您的位置: 首页 > 网络编程 > java开发 > 正文

求助:Weblogic下更新Timestamp字段报错 Data truncation: Incorrect datetime value

来源: 技术CTO 阅读:

项目在Tomcat下运行正常。但移植到weblogic下报错:

2012-08-03 14:48:42,046 ERROR [JDBCExceptionReporter.java:78] : Data truncation: Incorrect datetime value: '' for column 'LOGIN_TIME' at row 1
2012-08-03 14:48:42,046 ERROR [AbstractFlushingEventListener.java:301] : Could not synchronize database state with session
org.hibernate.exception.DataException: Could not execute JDBC batch update
at org.hibernate.exception.SQLStateConverter.convert(SQLStateConverter.java:77)
at org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:43)
at org.hibernate.jdbc.AbstractBatcher.executeBatch(AbstractBatcher.java:254)
at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:266)
at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:168)
at org.hibernate.event.def.AbstractFlushingEventListener.performExecutions(AbstractFlushingEventListener.java:298)
at org.hibernate.event.def.DefaultFlushEventListener.onFlush(DefaultFlushEventListener.java:27)
at org.hibernate.impl.SessionImpl.flush(SessionImpl.java:1001)
at org.hibernate.impl.SessionImpl.managedFlush(SessionImpl.java:339)
at org.hibernate.transaction.JDBCTransaction.commit(JDBCTransaction.java:106)
at org.springframework.orm.hibernate3.HibernateTransactionManager.doCommit(HibernateTransactionManager.java:656)
at org.springframework.transaction.support.AbstractPlatformTransactionManager.processCommit(AbstractPlatformTransactionManager.java:754)
at org.springframework.transaction.support.AbstractPlatformTransactionManager.commit(AbstractPlatformTransactionManager.java:723)
at org.springframework.transaction.interceptor.TransactionAspectSupport.commitTransactionAfterReturning(TransactionAspectSupport.java:393)
at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:120)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:171)
at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:204)
at $Proxy53.update(Unknown Source)
at com.nsc.framework.controller.system.UserLogin.login(UserLogin.java:74)
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.web.method.support.InvocableHandlerMethod.invoke(InvocableHandlerMethod.java:213)
at org.springframework.web.method.support.InvocableHandlerMethod.invokeForRequest(InvocableHandlerMethod.java:126)
at org.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod.invokeAndHandle(ServletInvocableHandlerMethod.java:96)
at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.invokeHandlerMethod(RequestMappingHandlerAdapter.java:617)
at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.handleInternal(RequestMappingHandlerAdapter.java:578)
at org.springframework.web.servlet.mvc.method.AbstractHandlerMethodAdapter.handle(AbstractHandlerMethodAdapter.java:80)
at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:923)
at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:852)
at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:882)
at org.springframework.web.servlet.FrameworkServlet.doPost(FrameworkServlet.java:789)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:727)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:820)
at weblogic.servlet.internal.StubSecurityHelper$ServletServiceAction.run(StubSecurityHelper.java:227)
at weblogic.servlet.internal.StubSecurityHelper.invokeServlet(StubSecurityHelper.java:125)
at weblogic.servlet.internal.ServletStubImpl.execute(ServletStubImpl.java:292)
at weblogic.servlet.internal.TailFilter.doFilter(TailFilter.java:26)
at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:42)
at org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:88)
at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:76)
at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:42)
at weblogic.servlet.internal.WebAppServletContext$ServletInvocationAction.run(WebAppServletContext.java:3496)
at weblogic.security.acl.internal.AuthenticatedSubject.doAs(AuthenticatedSubject.java:321)
at weblogic.security.service.SecurityManager.runAs(Unknown Source)
at weblogic.servlet.internal.WebAppServletContext.securedExecute(WebAppServletContext.java:2180)
at weblogic.servlet.internal.WebAppServletContext.execute(WebAppServletContext.java:2086)
at weblogic.servlet.internal.ServletRequestImpl.run(ServletRequestImpl.java:1406)
at weblogic.work.ExecuteThread.execute(ExecuteThread.java:201)
at weblogic.work.ExecuteThread.run(ExecuteThread.java:173)
Caused by: java.sql.BatchUpdateException: Data truncation: Incorrect datetime value: '' for column 'LOGIN_TIME' at row 1
at com.mysql.jdbc.ServerPreparedStatement.executeBatch(ServerPreparedStatement.java:651)
at com.mchange.v2.c3p0.impl.NewProxyPreparedStatement.executeBatch(NewProxyPreparedStatement.java:1723)
at org.hibernate.jdbc.BatchingBatcher.doExecuteBatch(BatchingBatcher.java:48)
at org.hibernate.jdbc.AbstractBatcher.executeBatch(AbstractBatcher.java:247)
... 48 more
<2012-8-3 下午02时48分42秒 CST> <Error> <HTTP> <BEA-101017> <[weblogic.servlet.internal.WebAppServletContext@171d6fa - appName: '_appsdir_oa_dir', name: 'oa', context-path: '/oa', spec-version: '2.5', request: weblogic.servlet.internal.ServletRequestImpl@1a6acb9[
POST /oa/system/userLogin.action HTTP/1.1
Connection: keep-alive
Content-Length: 43
Cache-Control: max-age=0
Origin: http://localhost:7001
User-Agent: Mozilla/5.0 (Windows NT 5.1) AppleWebKit/537.1 (KHTML, like Gecko) Chrome/21.0.1180.60 Safari/537.1
Content-Type: application/x-www-form-urlencoded
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
Referer: http://localhost:7001/oa/
Accept-Encoding: gzip,deflate,sdch
Accept-Language: zh-CN,zh;q=0.8,en;q=0.6
Accept-Charset: UTF-8,*;q=0.5
Cookie: JSESSIONID=29DAF469B802C5E6AD9D618E373717B9; JSESSIONID=Gh4LQbpTnnKZMMgy78j65wnXKQnGRXT76vQX4QhndDQKdjhfvbbR!2070493855; JSESSION1=ySpQQb0QsGKNgKVrpKfg2JCxQGwLnTDxJxbWxqTymvnnktGXxh4p!1825163971

]] Root cause of ServletException.
org.springframework.dao.DataIntegrityViolationException: Could not execute JDBC batch update; SQL [update T_USER set ROLE_CODE=?, LOGINID=?, PASSWORD=?, REALNAME=?, SEX=?, NATION=?, POSTIONAL=?, BIRTH=?, EMAIL=?, DUTY=?, LOGIN_TIME=?, LAST_LOGIN_TIME=?, LOGIN_COUNT=?, IS_USABLE=?, CREATOR=?, SIGN_TIME=?, MOBILE=?, TEL=?, QUETION=?, ANSWER=?, LOCK_TIME=?, TRY_COUNT=?, IS_INNER=? where CODE=?]; nested exception is org.hibernate.exception.DataException: Could not execute JDBC batch update
at org.springframework.orm.hibernate3.SessionFactoryUtils.convertHibernateAccessException(SessionFactoryUtils.java:648)
at org.springframework.orm.hibernate3.HibernateTransactionManager.convertHibernateAccessException(HibernateTransactionManager.java:793)
at org.springframework.orm.hibernate3.HibernateTransactionManager.doCommit(HibernateTransactionManager.java:664)
at org.springframework.transaction.support.AbstractPlatformTransactionManager.processCommit(AbstractPlatformTransactionManager.java:754)
at org.springframework.transaction.support.AbstractPlatformTransactionManager.commit(AbstractPlatformTransactionManager.java:723)
Truncated. see log file for complete stacktrace
org.hibernate.exception.DataException: Could not execute JDBC batch update
at org.hibernate.exception.SQLStateConverter.convert(SQLStateConverter.java:77)
at org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:43)
at org.hibernate.jdbc.AbstractBatcher.executeBatch(AbstractBatcher.java:254)
at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:266)
at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:168)
Truncated. see log file for complete stacktrace
java.sql.BatchUpdateException: Data truncation: Incorrect datetime value: '' for column 'LOGIN_TIME' at row 1
at com.mysql.jdbc.ServerPreparedStatement.executeBatch(ServerPreparedStatement.java:651)
at com.mchange.v2.c3p0.impl.NewProxyPreparedStatement.executeBatch(NewProxyPreparedStatement.java:1723)
at org.hibernate.jdbc.BatchingBatcher.doExecuteBatch(BatchingBatcher.java:48)
at org.hibernate.jdbc.AbstractBatcher.executeBatch(AbstractBatcher.java:247)
at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:266)
Truncated. see log file for complete stacktrace

找了很久没找到原因,求哪位大大解答。
我也在找原因呢
貌似是数据库中数据的原因,是不是创建索引的字段数据重复了,楼主排查一下。
Incorrect datetime value: '' for column 'LOGIN_TIME' at row 1

貌似这个参数你都没传进去吧?weblogic校验比tomcat严格,你看看用的那个字段是java.util.date还是java.sql.timestamp?
应该是你放在 weblogic 上运行时链接的 mysql 与你在  tomcat 上连接的 mysql 版本不一致造成的, 更新 mysql-connector.jar 即可
你看看 你的 LOGINID=?  这个传入进去的值是多少。 
我上网帮你找了一些原因  貌似还有可能是mysql版本的问题  说mysql5.6对时间类型有改动  5.5应该就行了   你看看你部署的时候mysql的版本是什么  会不会和weblogic对时间类型检查不符合

^_^ 如果您热爱技术、热爱编程,想与更多的朋友一起交流学习,欢迎加入本站官方QQ群:345733473 ^_^