4 Replies Latest reply: Sep 24, 2009 6:26 AM by 800467 RSS

    Throwing and catching SQL Exception

      Hi all

      I have the following method definition:
      public static Date getStartDate(aDate) throws SQLException
              return (Date) jdbcTemplate.queryForObject("select date from myTable", new Object[] {
                      aDate}, Date.class);
      As you can see this throws a SQLException. I call this code from a main method which has a try catch around the call catching for SQLException.

      I was expecting the catch in the main method to catch the exception but it seems to go somewhere else. This is pretty simple and I thought I had the concept understood - am I doing something obviously wrong here?

      I get the following: 'Exception in thread "main"'

      I forgot to mention this is throwing an exception because the query returns no data and is expecting a single row.

      Thanks for any tips

      Edited by: notforgoogle on Sep 23, 2009 3:52 AM