In the try catch block where you create the connection, you are catching ClassNotFoundException, and the SQLException, but then your method still continues. So, in the next block, where you try to use the connection, it's null because there was an exception in the previous block. Don't simply "log" an exception and continue (as you do for ClassNotFoundException) when the raising ...