Announcement Announcement Module
Collapse
No announcement yet.
Spring jdbc template - please help to resolve- Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Spring jdbc template - please help to resolve-

    Code:
    	public List<DashboardBean> fin(){
    
    		@SuppressWarnings("unchecked")
    		List<DashboardBean> dashboardBean = jdbcTemplate.query("select count(SLA_BREACHED) as SLA_EXCEED,count(WITHIN_SLA) WITHIN_SLA,count(*) TOT_SR,round((count(WITHIN_SLA)/count(*))*100,2) SLA_PER from (" +
    				"select CASE WHEN (DATE_COMMITED-CASE WHEN DATE_CLOSED  is null THEN SYSDATE ELSE DATE_CLOSED END)>=0 THEN SR_NUMBER END 'SLA_BREACHED'," +
    						" CASE WHEN (DATE_COMMITED-CASE WHEN DATE_CLOSED  is null THEN SYSDATE ELSE DATE_CLOSED END)<0 THEN SR_NUMBER END  'WITHIN_SLA'" +
    								"from sbl_service_request_v" +
    								"where SR_TYPE ='Complaint'" +
    								"and OWNING_DIVSION ='IT'" +
    								"and ASSIGNED_DIVISION  = 'CSO'" +
    								"and to_char(ASSIGNED_DATETIME,'MM-YY') =to_char(sysdate,'MM-YY'))",
    						new Object[] {},
    						new RowMapper() {
    							public DashboardBean mapRow(ResultSet rs, int rowNum)
    									throws SQLException {
    								DashboardBean dashboardBean = new DashboardBean();
    								dashboardBean.setSlaExceed(Integer.valueOf(rs.getString("SLA_EXCEED")));
    								dashboardBean.setWithinSla(Integer.valueOf(rs.getString("WITHIN_SLA")));
    								dashboardBean.setTotSr(Integer.valueOf(rs.getString("TOT_SR")));
    								dashboardBean.setSlaPer(Double.valueOf(rs.getString("SLA_PER")));
    								return dashboardBean;
    							}
    
    						});
    
    		return dashboardBean;
    	}


    My Error was like this :

    Code:
    java.lang.NullPointerException
    	at com.priyan.contact.dao.ContactDAOImpl.fin(ContactDAOImpl.java:39)
    	at com.priyan.contact.service.ContactServiceImpl.fin(ContactServiceImpl.java:43)
    	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.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:309)
    	at org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:183)
    	at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:150)
    	at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:110)
    	at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)
    	at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:202)
    	at $Proxy27.fin(Unknown Source)
    	at com.priyan.contact.controller.ContactController.listAllContacts(ContactController.java:69)
    	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

    above QUERY was running successfully in my ORACLE DB Tool (Ex: TOAD )

    Error Mentioned line was above my DAO Class Query defined line..

    plesae help me friends?
    are there any mistake with my SQL code ?

  • #2
    Have you actually READ the stacktrace? Judging from that you aren't using the dao from the context but creating a new one inside your service.

    Comment


    • #3
      Thanks Marten

      Originally posted by Marten Deinum View Post
      Have you actually READ the stacktrace? Judging from that you aren't using the dao from the context but creating a new one inside your service.
      Thanks again for your earlier reply.
      but i can't get idea about 'Stacktrace'. please tell me wat z you mean by it ?

      earlier i enter simple select quey without rowmapper & used SysOut & console showed that.
      i think error with my SQL Code.

      please assist friend..

      Comment


      • #4
        If you don't know what a stack trace is I suggest starting to read on java first.

        As stated the error isn't in your query it is in the way you use your code. As stated you are probably creating a new instance of your dao in your service.

        Comment


        • #5
          Marten,

          Originally posted by Marten Deinum View Post
          you are probably creating a new instance of your dao in your service.
          please explain the above sentence friend..i haven't idea about it

          [sorry for my english :-) ]

          Comment


          • #6
            You really seem to be missing basic java concepts I suggest a java tutorial/read before progressing? I cannot state it more clearly then that you are creating a new instance of your dao in the service.

            Comment

            Working...
            X