aspose file tools*
The moose likes JDBC and the fly likes java.lang.NullPointerException Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Databases » JDBC
Bookmark "java.lang.NullPointerException" Watch "java.lang.NullPointerException" New topic
Author

java.lang.NullPointerException

Farakh khan
Ranch Hand

Joined: Mar 22, 2008
Posts: 732
Hello,

My following code throws java.lang.NullPointerException



StackTrace:

Line
470: tempClob.freeTemporary();
492: edu = getClob(education, cnn);

Thanks in anticipation

Mohamed Sanaulla
Saloon Keeper

Joined: Sep 08, 2007
Posts: 3071
    
  33

You see in the sample code you have posted- at Line 2 - tempClob is null and its initialized only in the try block. But when its being used in the catch block it may be or may not be initialized.
May be because- CLOB.createTemporary successfully executes.
May not be because- there was some exception while executing CLOB.createTemporary and hence tempClob is not initialized.

So in you catch you need to check if tempClob is initialized before you execute tasks of cleaning.


Mohamed Sanaulla | My Blog
Farakh khan
Ranch Hand

Joined: Mar 22, 2008
Posts: 732
I am not able to fix it
Mohamed Sanaulla
Saloon Keeper

Joined: Sep 08, 2007
Posts: 3071
    
  33

In your catch block you add this check-


But the cleanup has to be done in finally - catch block may not be executed when there is no exception. But finally block is always executed. So you have to add
Farakh khan
Ranch Hand

Joined: Mar 22, 2008
Posts: 732
Now its throwing the following exception:
Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 18651
    
    8

Okay. And do you have a particular question about that stack trace?
Farakh khan
Ranch Hand

Joined: Mar 22, 2008
Posts: 732
UserDAO.insertInToDetailResume(UserDAO.java:196) is:


BulkUpload.doPost(BulkUpload.java:239) is:


 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: java.lang.NullPointerException