jdbc使用经验~

今天操作Sql Server 2000数据库时用hibernateTemplate更新一个对象时     

 this.getHibernateTemplate().update(service);            

service是一个对象里面有ID和Content String类型等    ,  我只修改了Content内容   

这时遇到个异常 

org.hibernate.exception.GenericJDBCException: could not update: [com.gnet.mis.dao.pojo.GnetMisBookingService#component[BookingNo,ServiceId]{ServiceId=226, BookingNo=990003-226-HT01-DD17}]
 at org.hibernate.exception.SQLStateConverter.handledNonSpecificException(SQLStateConverter.java:103)
 at org.hibernate.exception.SQLStateConverter.convert(SQLStateConverter.java:91)
 at org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:43)
 at org.hibernate.persister.entity.AbstractEntityPersister.update(AbstractEntityPersister.java:2425)
 at org.hibernate.persister.entity.AbstractEntityPersister.updateOrInsert(AbstractEntityPersister.java:2307)
 at org.hibernate.persister.entity.AbstractEntityPersister.update(AbstractEntityPersister.java:2607)
 at org.hibernate.action.EntityUpdateAction.execute(EntityUpdateAction.java:92)
 at org.hibernate.engine.ActionQueue.execute(ActionQueue.java:250)
 at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:234)
 at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:142)
 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:1000)
 at org.hibernate.impl.SessionImpl.managedFlush(SessionImpl.java:338)
 at org.hibernate.transaction.JDBCTransaction.commit(JDBCTransaction.java:106)
 at org.springframework.orm.hibernate3.HibernateTransactionManager.doCommit(HibernateTransactionManager.java:575)
 at org.springframework.transaction.support.AbstractPlatformTransactionManager.processCommit(AbstractPlatformTransactionManager.java:662)
 at org.springframework.transaction.support.AbstractPlatformTransactionManager.commit(AbstractPlatformTransactionManager.java:632)
 at org.springframework.transaction.interceptor.TransactionAspectSupport.commitTransactionAfterReturning(TransactionAspectSupport.java:314)
 at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:117)
 at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:166)
 at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:204)
 at $Proxy52.updateGnetMisBookingService(Unknown Source)
 at com.gnet.mis.struts.action.BookingManagerAction.updateBookingService(BookingManagerAction.java:1800)
 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:585)
 at org.apache.struts.actions.DispatchAction.dispatchMethod(DispatchAction.java:280)
 at org.apache.struts.actions.DispatchAction.execute(DispatchAction.java:216)
 at com.gnet.mis.framework.struts.BaseDispatchAction.execute(BaseDispatchAction.java:42)
 at org.apache.struts.action.RequestProcessor.processActionPerform(RequestProcessor.java:484)
 at org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:274)
 at org.apache.struts.action.ActionServlet.process(ActionServlet.java:1482)
 at org.apache.struts.action.ActionServlet.doPost(ActionServlet.java:525)
 at javax.servlet.http.HttpServlet.service(HttpServlet.java:710)
 at javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
 at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
 at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
 at com.gnet.mis.framework.struts.CharacterCodeFilter.doFilter(CharacterCodeFilter.java:71)
 at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
 at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
 at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:230)
 at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:175)
 at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:128)
 at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:104)
 at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
 at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:261)
 at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:844)
 at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:581)
 at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:447)
 at java.lang.Thread.run(Thread.java:595)
Caused by: java.sql.SQLException: [Microsoft][SQLServer 2000 Driver for JDBC]The DBMS returned an unspecified error.
 at com.microsoft.jdbc.base.BaseExceptions.createException(Unknown Source)
 at com.microsoft.jdbc.base.BaseExceptions.getException(Unknown Source)
 at com.microsoft.jdbc.sqlserver.tds.TDSRequest.processReplyToken(Unknown Source)
 at com.microsoft.jdbc.sqlserver.tds.TDSRPCRequest.processReplyToken(Unknown Source)
 at com.microsoft.jdbc.sqlserver.tds.TDSRequest.processReply(Unknown Source)
 at com.microsoft.jdbc.sqlserver.SQLServerImplStatement.getNextResultType(Unknown Source)
 at com.microsoft.jdbc.base.BaseStatement.commonTransitionToState(Unknown Source)
 at com.microsoft.jdbc.base.BaseStatement.postImplExecute(Unknown Source)
 at com.microsoft.jdbc.base.BasePreparedStatement.postImplExecute(Unknown Source)
 at com.microsoft.jdbc.base.BaseStatement.commonExecute(Unknown Source)
 at com.microsoft.jdbc.base.BaseStatement.executeUpdateInternal(Unknown Source)
 at com.microsoft.jdbc.base.BasePreparedStatement.executeUpdate(Unknown Source)
 at org.apache.commons.dbcp.DelegatingPreparedStatement.executeUpdate(DelegatingPreparedStatement.java:102)
 at org.hibernate.jdbc.NonBatchingBatcher.addToBatch(NonBatchingBatcher.java:23)
 at org.hibernate.persister.entity.AbstractEntityPersister.update(AbstractEntityPersister.java:2403)
 ... 48 more 

打了断点,确认代码没出异常..在一个org.springframework.aop.framework.JdkDynamicAopProxy.invoke 跳出异常

换了个开源的ms jdbc驱动 JTDS  配置如下:

JTDS 下载地址: http://sourceforge.net/project/showfiles.php?group_id=33291
driver = net.sourceforge.jtds.jdbc.Driver
url = jdbc:jtds:sqlserver://localhost:1433;
一切正常~~~~!!!            在网上看见很多人都说ms的 jdbc驱动有问题.今天算时见识到了.
还有org.gjt.mm.mysql.Driver  和 com.mysql.jdbc.Driver 区别 :
1.org.gjt.mm.mysql.Driver 是以前com.mysql.jdbc.Driver前身  如果你不想出麻烦 现在都推荐用com.mysql.jdbc.Driver
2.org.gjt.mm.mysql.Driver  内部其实就是Extends   com.mysql.jdbc.Driver.  为了保持对老版本的兼容才而保留
总的来说..都是一个人,喊的绰号不同罢了~~
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值