Check the statement if it is null before closing it.
 
Vj
 
----- Original Message -----
Sent: Tuesday,February 04,2003 11:43 PM
Subject: Weird database problem & catching exception

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.
 
 
 

 

Reply via email to