Results 1 to 3 of 3
  1. #1
    leapinlizard is offline Member
    Join Date
    Apr 2009
    Posts
    19
    Rep Power
    0

    Default Null Pointer exception

    Hi,

    I'm new to Spring. I have created one JUnit Test and trying to run but I'm getting the following error:

    java.lang.NullPointerException

    Java Code:
    public void testCarIdFilter() {
            final CarIdFilter  carIdFilter = new carIdFilter();
            final String SELECT_SQL = "SELECT  * FROM CAR_ID_FILTER";
            
            QueryBuilder query=new QueryBuilder(new StringBuffer().append(SELECT_SQL));
            
            try {
                getJdbcTemplate().query(query.getSql(), query.getParms(),new ServiceIdRowMapper(){
                       public void processRow(ResultSet rs)throws SQLException{
                        carIdFilter.setServiceId(rs.getString("Service_Id"));
                        carIdFilter.setVinCode(rs.getString("Vin_Code"));
                        carIdFilter.setAltId(rs.getString("Alt_Id"));
                       }}
                 );
                }catch (IncorrectResultSizeDataAccessException e) {
                  e.printStackTrace();
               }
         }   
            
    		
    		class CarIdRowMapper implements RowMapper {
            public Object mapRow(ResultSet rs, int index) throws SQLException {
               CarIdFilter carIdFilter = new CarIdFilter();
                carIdFilter.setServiceId(rs.getString("Service_Id"));
                carIdFilter.setVinCode(rs.getString("Vin_Code"));
                carIdFilter.setAlt_Id(rs.getString("Alt_Id"));
                
                
                return carIdFilter;
            }      
        }

    Any input would be appreciated.

    Sorry, If I post in wrong category. Brain stop working at the moment.

    Thanks!

  2. #2
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    11,931
    Rep Power
    19

    Default Re: Null Pointer exception

    That exception will come with a stack trace.
    That stack trace will tell you which line your null pointer exception is occurring on.
    Please do not ask for code as refusal often offends.

    ** This space for rent **

  3. #3
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    11,931
    Rep Power
    19

    Default Re: Null Pointer exception

    Oh, and can you please format your code properly, as your brackets and indenting is all over the place.
    Please do not ask for code as refusal often offends.

    ** This space for rent **

Similar Threads

  1. Null pointer exception
    By mathidioticz in forum New To Java
    Replies: 12
    Last Post: 02-04-2012, 06:38 PM
  2. null pointer exception
    By russellty in forum New To Java
    Replies: 11
    Last Post: 02-04-2012, 05:04 PM
  3. Null pointer exception
    By jessie in forum New To Java
    Replies: 5
    Last Post: 02-08-2011, 02:58 PM
  4. Null pointer exception
    By samuel.roshni in forum Java Servlet
    Replies: 14
    Last Post: 01-22-2011, 02:25 PM
  5. null pointer exception
    By jyothi.priyanka in forum New To Java
    Replies: 12
    Last Post: 03-11-2009, 05:04 PM

Posting Permissions

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