Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Java > Re: java.lang.NullPointerException (Tomcat)

Reply
Thread Tools

Re: java.lang.NullPointerException (Tomcat)

 
 
Dhek Bhun Kho
Guest
Posts: n/a
 
      07-08-2003
Original message from (shaab mohagir) on Thu, 22
May 2003 19:12:44 -0700:

SM> The JavaBean code compiles and runs fine off line, I can connect to
SM> the DB I get my results correct and everything is smooth until I try
SM> to use the bean in a JSP page.

Have you made sure the driver is available within the context? (place it
in the correct directory of the WEB-INF)

SM> root cause
SM>
SM> java.lang.NullPointerException
SM> at star.TAStatus.getCount(TAStatus.java:50)
SM>
This could be anything,

I don't know where line 50 it (:set nonu in vi points it at the return
rst.getString()).

If it did happen at the return rst.getString() then there must
be some message logged in your logfile if you have turned loggin on.

You should have rethrown the SQLException in the catch clause.
Since if the connection does not exist, your servlet will not detect it as
such, and you will get a NullPointerException instead.

Furthermore you are introducing a possible bug. You call
rst.next() but do not check on the return value, the servlet will probably
crash in such an event.

Greets.
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off




Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57