Results 1 to 6 of 6

Thread: Spring jdbc template - please help to resolve-

  1. #1
    Join Date
    Sep 2010
    Location
    Sri Lanka
    Posts
    61

    Question 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. #2
    Join Date
    Jun 2006
    Location
    The Netherlands
    Posts
    13,629

    Default

    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.
    Marten Deinum
    Java Consultant / Pragmatist / Open Source Enthousiast / Author


    Pro Spring MVC: With Web Flow
    Conspect

    Have you read the reference guide.
    Use the [ code ] tags, young padawan

  3. #3
    Join Date
    Sep 2010
    Location
    Sri Lanka
    Posts
    61

    Question Thanks Marten

    Quote 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..

  4. #4
    Join Date
    Jun 2006
    Location
    The Netherlands
    Posts
    13,629

    Default

    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.
    Marten Deinum
    Java Consultant / Pragmatist / Open Source Enthousiast / Author


    Pro Spring MVC: With Web Flow
    Conspect

    Have you read the reference guide.
    Use the [ code ] tags, young padawan

  5. #5
    Join Date
    Sep 2010
    Location
    Sri Lanka
    Posts
    61

    Default

    Marten,

    Quote 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 :-) ]

  6. #6
    Join Date
    Jun 2006
    Location
    The Netherlands
    Posts
    13,629

    Default

    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.
    Marten Deinum
    Java Consultant / Pragmatist / Open Source Enthousiast / Author


    Pro Spring MVC: With Web Flow
    Conspect

    Have you read the reference guide.
    Use the [ code ] tags, young padawan

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •