Weird database problem & catching exception

Tom Kochanowicz <[email protected]>
Newsgroups gmane.comp.java.sun.servlet
Message-ID <000001c2cc79$1bd97360$21010101@developer>
I am using MySQL with Resin. Recently there has been a lot of discussion
on this list about closing database statements and problems. Has anyone
run into this one?

I have this finally statement
finally{
      try{
        // close the statments & DB connection
        insertStatementAdInfoView.close();
        dbConnection.close();
      }catch(Exception e){   // SQLException doesn't work
      System.out.println("Problem with insertStatementAdInfoView " + e);
      }
    }

When I catch an SQLException I get a java.lang.NullPointerException and
it crashes. When I catch with just Exception, I still get a
NullPointerException but the program works! I thought the SQLException
should handle this. Why am I getting a NullPointerException (500 Servlet
Exception)exception when I am just doing an insert into a database? The
insert, inserts the data even with the NullPointerException when
catching it with Exception. What could be causing this exception when I
am simply using a getParameter to read a jsp entry and doing an insert
with a prepared statement?

T.K.
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.