Announcement Announcement Module
Collapse
No announcement yet.
problem in executing a sql query Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • problem in executing a sql query

    public StockData GetLastTrade(String UserName, String SymbolName, StockData stockData)
    {
    System.out.println("error in GetLastTrade " + SymbolName + "username==" + UserName + "TRANSDATE ==" + stockData.getTRANSDATE() + "OPENPRICE==" + stockData.getOPENPRICE());

    try{
    System.out.println("GetLastTrade done==" + stockData.getTRANSDATE());

    return stockDataService.GetLastTrade(UserName, SymbolName, stockData);
    }
    catch(Exception e){
    System.out.println("stockDataService.GetLastTrade error" +e);
    e.printStackTrace();
    }
    return stockData;
    }


    this is int countStockData in my code :



    public int countStockData(String UserName, String SymbolName, StockData stockData) {



    String transdateforquery = stockData.getTRANSDATE();

    try {
    return template
    .queryForInt(
    "SELECT COUNT(TRANSDATE) FROM stockdata WHERE transdate= ? AND symbolname = ?",
    rowMapper,transdateforquery, SymbolName);
    } catch (TransientDataAccessResourceException e) {
    System.out.println("TransientDataAccessResourceExc eption====");
    // TODO Auto-generated catch block
    e.printStackTrace();
    return 0;
    }





    IM getting this error:


    TransientDataAccessResourceException====
    org.springframework.dao.TransientDataAccessResourc eException: PreparedStatementCallback; SQL [SELECT COUNT(TRANSDATE) FROM stockdata WHERE transdate= ? AND symbolname = ?]; Invalid argument value: java.io.NotSerializableException; nested exception is java.sql.SQLException: Invalid argument value: java.io.NotSerializableException
    at org.springframework.jdbc.support.SQLStateSQLExcept ionTranslator.doTranslate(SQLStateSQLExceptionTran slator.java:107)
    at org.springframework.jdbc.support.AbstractFallbackS QLExceptionTranslator.translate(AbstractFallbackSQ LExceptionTranslator.java:72)
    at org.springframework.jdbc.support.AbstractFallbackS QLExceptionTranslator.translate(AbstractFallbackSQ LExceptionTranslator.java:80)
    at org.springframework.jdbc.support.AbstractFallbackS QLExceptionTranslator.translate(AbstractFallbackSQ LExceptionTranslator.java:80)
    at org.springframework.jdbc.core.JdbcTemplate.execute (JdbcTemplate.java:602)
    at org.springframework.jdbc.core.JdbcTemplate.query(J dbcTemplate.java:636)
    at org.springframework.jdbc.core.JdbcTemplate.query(J dbcTemplate.java:665)
    at org.springframework.jdbc.core.JdbcTemplate.query(J dbcTemplate.java:673)
    at org.springframework.jdbc.core.JdbcTemplate.queryFo rObject(JdbcTemplate.java:716)
    at org.springframework.jdbc.core.JdbcTemplate.queryFo rObject(JdbcTemplate.java:727)
    at org.springframework.jdbc.core.JdbcTemplate.queryFo rInt(JdbcTemplate.java:754)
    at org.springframework.jdbc.core.simple.SimpleJdbcTem plate.queryForInt(SimpleJdbcTemplate.java:121)
    at com.ib.client.mts.backend.DAO.StockDataService.cou ntStockData(StockDataService.java:362)
    at com.ib.client.mts.backend.BusinessService.TradingB usinessService.GetStockDataCount(TradingBusinessSe rvice.java:262)
    at com.ib.client.mts.backend.BusinessService.MtsRuleE ngineService.AnalyseRow(MtsRuleEngineService.java: 205)
    at com.ib.client.mts.backend.DAO.UploadDAO.csvinput(U ploadDAO.java:175)
    at com.ib.client.mts.backend.DAO.FileUploadService.do Upload(FileUploadService.java:42)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Nativ e Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(Unknow n Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(Un known Source)
    at java.lang.reflect.Method.invoke(Unknown Source)
    at flex.messaging.services.remoting.adapters.JavaAdap ter.invoke(JavaAdapter.java:421)
    at flex.messaging.services.RemotingService.serviceMes sage(RemotingService.java:183)
    at flex.messaging.MessageBroker.routeMessageToService (MessageBroker.java:1503)
    at flex.messaging.endpoints.AbstractEndpoint.serviceM essage(AbstractEndpoint.java:884)
    at flex.messaging.endpoints.AbstractEndpoint$$FastCla ssByCGLIB$$1a3ef066.invoke(<generated>)
    at net.sf.cglib.proxy.MethodProxy.invoke(MethodProxy. java:191)
    at org.springframework.aop.framework.Cglib2AopProxy$C glibMethodInvocation.invokeJoinpoint(Cglib2AopProx y.java:692)
    at org.springframework.aop.framework.ReflectiveMethod Invocation.proceed(ReflectiveMethodInvocation.java :150)
    at org.springframework.aop.framework.adapter.ThrowsAd viceInterceptor.invoke(ThrowsAdviceInterceptor.jav a:124)
    at org.springframework.aop.framework.ReflectiveMethod Invocation.proceed(ReflectiveMethodInvocation.java :172)
    at org.springframework.aop.framework.Cglib2AopProxy$F ixedChainStaticTargetInterceptor.intercept(Cglib2A opProxy.java:576)
    at flex.messaging.endpoints.AMFEndpoint$$EnhancerByCG LIB$$3cc0debb.serviceMessage(<generated>)
    at flex.messaging.endpoints.amf.MessageBrokerFilter.i nvoke(MessageBrokerFilter.java:121)
    at flex.messaging.endpoints.amf.LegacyFilter.invoke(L egacyFilter.java:158)
    at flex.messaging.endpoints.amf.SessionFilter.invoke( SessionFilter.java:44)
    at flex.messaging.endpoints.amf.BatchProcessFilter.in voke(BatchProcessFilter.java:67)
    at flex.messaging.endpoints.amf.SerializationFilter.i nvoke(SerializationFilter.java:146)


    at org.springframework.security.ui.SpringSecurityFilt er.doFilter(SpringSecurityFilter.java:53)
    at org.springframework.security.util.FilterChainProxy $VirtualFilterChain.doFilter(FilterChainProxy.java :390)
    at org.springframework.security.util.FilterChainProxy .doFilter(FilterChainProxy.java:175)
    at org.springframework.web.filter.DelegatingFilterPro xy.invokeDelegate(DelegatingFilterProxy.java:238)
    25more
    org.apache.coyote.http11.Http11AprProtocol$Http11C onnectionHandler.process(Http11AprProtocol.java:56 5)
    at org.apache.tomcat.util.net.AprEndpoint$Worker.run( AprEndpoint.java:1509)
    at java.lang.Thread.run(Unknown Source)


    whats the problem in the above code and what will be the new code.I m new to spring so facing problems

  • #2
    Hi...check for the proper syntax and try it out again....!!!!

    Comment


    • #3
      $enviar_sql = mysql_query($habitaciones, $enlace); with this:

      $enviar_sql = mysql_query($habitaciones, $enlace) or die(mysql_error());
      While this is an awful way to handle errors and should not be used except to fix whatever issue there is with your query it's a good way to quickly find out what's going wrong.

      WEB DESIGN SEARCH ENGINE OPTIMIZATION PAY PER CLICK SOCIAL MEDIA MARKETING Dgtpoint
      STATIC WEB DESIGNING DYNAMIC WEB DESIGNING

      Comment


      • #4
        hi dear
        Since Spring just throws RuntimeException(s) you can remove your exception handling and have a look at the stacktrace which will tell you more about the object not being serializeable.

        Comment

        Working...
        X