java - Spring MVC Stack Over Flow Error - trying to get data from database -
i have form inserts database before preform insert check if there existing records. unable insert record , getting stackoverflow error.
can tell me causes error , can rid of it. if remove check hasrecords code preforms fine. code doesn't want access database @ point. have created different types of function preform check here records @ point keep getting same error stackoverflow
code
com.crimetrack.service.monitoringmanager.getmonitoringstdate(monitoringmanager.java:60)
public string getmonitoringstdate(integer crimerecno, integer socialsecuritynumber) throws exception { return this.getmonitoringstdate(crimerecno, socialsecuritynumber); }
dao getmonitoringstdate
public string getmonitoringstdate(integer crimerecno, integer socialsecuritynumber){ //select minimum start date in event there several records although not allowed string sql = "select ifnull(min(monitoringstdate),'0') monitoringstdate tblmonitoring crimerecno = ? , socialsecuritynumber = ?"; string monitoringstdate = (string)getjdbctemplate().queryforobject(sql, new object[]{crimerecno,socialsecuritynumber}, string.class); return monitoringstdate; }
i have following listeners registered:
listeners
<listener> <listener-class>org.springframework.web.context.contextloaderlistener</listener-class> </listener> <listener> <listener-class>org.springframework.web.context.request.requestcontextlistener</listener-class> </listener>
code
dao
public boolean hasmonitoringrecord(integer crimerecno, integer socialsecuritynumber){ //select count of monitoring records there should 1 monitoring record string sql = "select count(*) monitoringstdate tblmonitoring crimerecno = ? , socialsecuritynumber = ?"; integer count = (integer)getjdbctemplate().queryforobject(sql, new object[]{crimerecno,socialsecuritynumber}, integer.class); if(count > 0 ){ return true; }else{ return false; } }
controller
if(result.haserrors()){ mymonitoringtypelist.put("monitoringtypelist",this.monitoringtypemanager.getlistofmonitoringtype()); model.addattribute("icon", "ui-icon ui-icon-circle-close"); model.addattribute("results", "error: unable save record!"); model.addattribute("monitoringtype",mymonitoringtypelist); model.addattribute("monitoring",monitoring); model.addattribute("records", session.getattribute("records")); model.addattribute("crimerecno",session.getattribute("crimerecno")); //return user page on not first page 1 error return new modelandview("monitoringlist","page",session.getattribute("page")); }else{ int crimerecno = monitoring.getcrimerecno(); int socialsecuritynumber = monitoring.getsocialsecuritynumber(); logger.info("no errors going process records"); logger.info("crimerecno " + monitoring.getcrimerecno()); logger.info("socialsecurity number " + monitoring.getsocialsecuritynumber()); //check if record exists. if 1 exist update else insert //to check if record exists can start date string dbmonitoringstdate = monitoringmanager.getmonitoringstdate(crimerecno,socialsecuritynumber); logger.info("the dbmonitoringstdate " + dbmonitoringstdate); if(monitoringmanager.hasmonitoringrecord(crimerecno, socialsecuritynumber)){ logger.info("has monitoring record"); //do update monitoringmanager.updatemonitoringrecord(monitoring); model.addattribute("icon", "ui-icon ui-icon-circle-check"); model.addattribute("results", "record updated"); }else { logger.info("does not have monitoring record"); //do insert monitoringmanager.savemonitoringrecord(monitoring); model.addattribute("icon", "ui-icon ui-icon-circle-check"); model.addattribute("results", "record saved"); }
error
7035 [http-bio-8084-exec-1] debug org.springframework.web.servlet.dispatcherservlet - cleared thread-bound request context: org.apache.catalina.connector.requestfacade@6f138f45 7035 [http-bio-8084-exec-1] debug org.springframework.web.servlet.dispatcherservlet - not complete request org.springframework.web.util.nestedservletexception: handler processing failed; nested exception java.lang.stackoverflowerror @ org.springframework.web.servlet.dispatcherservlet.dodispatch(dispatcherservlet.java:972) @ org.springframework.web.servlet.dispatcherservlet.doservice(dispatcherservlet.java:852) @ org.springframework.web.servlet.frameworkservlet.processrequest(frameworkservlet.java:882) @ org.springframework.web.servlet.frameworkservlet.dopost(frameworkservlet.java:789) @ javax.servlet.http.httpservlet.service(httpservlet.java:647) @ javax.servlet.http.httpservlet.service(httpservlet.java:728) @ org.apache.catalina.core.applicationfilterchain.internaldofilter(applicationfilterchain.java:305) @ org.apache.catalina.core.applicationfilterchain.dofilter(applicationfilterchain.java:210) @ org.apache.catalina.core.standardwrappervalve.invoke(standardwrappervalve.java:222) @ org.apache.catalina.core.standardcontextvalve.invoke(standardcontextvalve.java:123) @ org.apache.catalina.authenticator.authenticatorbase.invoke(authenticatorbase.java:472) @ org.apache.catalina.core.standardhostvalve.invoke(standardhostvalve.java:171) @ org.apache.catalina.valves.errorreportvalve.invoke(errorreportvalve.java:99) @ org.apache.catalina.valves.accesslogvalve.invoke(accesslogvalve.java:936) @ org.apache.catalina.core.standardenginevalve.invoke(standardenginevalve.java:118) @ org.apache.catalina.connector.coyoteadapter.service(coyoteadapter.java:407) @ org.apache.coyote.http11.abstracthttp11processor.process(abstracthttp11processor.java:1004) @ org.apache.coyote.abstractprotocol$abstractconnectionhandler.process(abstractprotocol.java:589) @ org.apache.tomcat.util.net.jioendpoint$socketprocessor.run(jioendpoint.java:310) @ java.util.concurrent.threadpoolexecutor.runworker(unknown source) @ java.util.concurrent.threadpoolexecutor$worker.run(unknown source) @ java.lang.thread.run(unknown source) caused by: java.lang.stackoverflowerror @ com.crimetrack.service.monitoringmanager.getmonitoringstdate(monitoringmanager.java:60) @ com.crimetrack.service.monitoringmanager.getmonitoringstdate(monitoringmanager.java:60) @ com.crimetrack.service.monitoringmanager.getmonitoringstdate(monitoringmanager.java:60) @ com.crimetrack.service.monitoringmanager.getmonitoringstdate(monitoringmanager.java:60) @ com.crimetrack.service.monitoringmanager.getmonitoringstdate(monitoringmanager.java:60)
look @ method definition:
public string getmonitoringstdate(integer crimerecno, integer socialsecuritynumber) throws exception { return this.getmonitoringstdate(crimerecno, socialsecuritynumber); }
the thing method calling itself. obviously, have infinite recursion loop.
Comments
Post a Comment