27-Apr 13:21:35 INFO CameraDetailsDaoImpl [] - org.springframework.jdbc.UncategorizedSQLException: Hibernate operation: could not execute query; uncategorized SQLException for SQL [UPDATE cctvcamera SET police_station_name='T T Nagar Police Station', url='', latitude=23.23528492, longitude=77.40121292, junction_name='Top N Town New Market Point',police_station_id=17 WHERE cameraid=2]; SQL state [null]; error code [0]; The statement did not return a result set.; nested exception is com.microsoft.sqlserver.jdbc.SQLServerException: The statement did not return a result set.
27-Apr 13:21:35 ERROR CameraDetailsDaoImpl [] - updateAlertDetails()
java.lang.NullPointerException
at org.trinity.admin.dao.cameramanagement.CameraDetailsDaoImpl.updateCameraDetails(CameraDetailsDaoImpl.java:119)
at org.trinity.admin.service.cameramanagement.CameraSerivce.updateCameraDetails(CameraSerivce.java:33)
at org.trinity.admin.service.cameramanagement.CameraSerivce$$FastClassByCGLIB$$4a96f69.invoke(<generated>)
at net.sf.cglib.proxy.MethodProxy.invoke(MethodProxy.java:191)
at org.springframework.aop.framework.Cglib2AopProxy$DynamicAdvisedInterceptor.intercept(Cglib2AopProxy.java:617)
at org.trinity.admin.service.cameramanagement.CameraSerivce$$EnhancerByCGLIB$$8389c032_2.updateCameraDetails(<generated>)
at org.trinity.admin.controller.cameramanagement.CameraManagementController.updateCameraDetails(CameraManagementController.java:148)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.springframework.web.bind.annotation.support.HandlerMethodInvoker.invokeHandlerMethod(HandlerMethodInvoker.java:176)
at org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter.invokeHandlerMethod(AnnotationMethodHandlerAdapter.java:426)
at org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter.handle(AnnotationMethodHandlerAdapter.java:414)
at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:790)
at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:719)
at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:644)
at org.springframework.web.servlet.FrameworkServlet.doPost(FrameworkServlet.java:560)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:646)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:727)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:303)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:220)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:122)
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:503)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:170)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:103)
at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:950)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:116)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:421)
at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1070)
at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:611)
at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:316)
at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
at java.lang.Thread.run(Unknown Source)
我的代码:
queryUpdate="UPDATE cctvcamera SET police_station_name='"
+list.get(0)+"', url='"+pojo.getUrl()+"',latitude="
+pojo.getLatitude()+",longitude="
+pojo.getLongitude()+", junction_name='"
+pojo.getJunctionName()+"', police_station_id="
+pojo.getPoliceStationName()
+" WHERE cameraid="+pojo.getCameraid()+"";
try {
list1=getHibernateTemplateDCRMS().executeFind(new HibernateCallback() {
@Override
public Object doInHibernate(Session session)
throws HibernateException, SQLException {
Query q=session.createSQLQuery(queryUpdate);
return q.list();
}
});
使用Micro soft SQL Server 2008
答案 0 :(得分:1)
请使用executeUpdate方法而不是使用executeQuery来执行更新操作;
com.microsoft.sqlserver.jdbc.SQLServerException: The statement did not return a result set.
答案 1 :(得分:1)
在您的代码中,您正在调用query.list()
,如果您想在数据库上运行select查询,此方法很有用。
将其替换为executeUpdate
,如下所示:
@Override
public Object doInHibernate(Session session) throws HibernateException, SQLException {
Query q=session.createSQLQuery(queryUpdate);
return q.executeUpdate();
}
答案 2 :(得分:1)
感谢您的回复。
我得到了解决方案,我已经用代码
替换了我的旧代码 。getHibernateTemplateDCRMS()bulkUpdate(queryUpdate);
//其中queryUpdate是查询字符串