• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Tim Cooke
  • Jeanne Boyarsky
  • Bear Bibeault
Sheriffs:
  • Knute Snortum
  • paul wheaton
  • Devaka Cooray
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Ron McLeod
  • Piet Souris
  • Ganesh Patekar
Bartenders:
  • Tim Holloway
  • Carey Brown
  • salvin francis

While loop broke while retrieving data.

 
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi everyone,
i have 3 tables "Subject","Prerequisite",and "DEP_PREREQ" the least was made to handle a many to many relation
(Screenshots included as attachments)
i wrote this to return a list of specific columns

but when it reached the line with asterisk (line:17) the loop just stooped and an empty list was returned, why this happened?
dep_prereq.png
[Thumbnail for dep_prereq.png]
prerequisite.png
[Thumbnail for prerequisite.png]
subject.png
[Thumbnail for subject.png]
 
Master Rancher
Posts: 4223
47
  • Likes 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Your method is structured like this:


Now, If an exception other than a SQLException is thrown then you will never know, because you have put a return in the finally clause.  That exception will be lost entirely.

Move the return statement outside the finally block and then you'll see the exception that is happening, and that you are hiding at the moment.
 
Bartender
Posts: 1168
38
IBM DB2 Netbeans IDE Spring Java
  • Likes 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
And welcome to the ranch !
 
Abdullah khaled
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Dave Tolls wrote:Your method is structured like this:


Now, If an exception other than a SQLException is thrown then you will never know, because you have put a return in the finally clause.  That exception will be lost entirely.

Move the return statement outside the finally block and then you'll see the exception that is happening, and that you are hiding at the moment.



thank you so much, now i got a NullPointerException in the same line however my query works as it should in SQLDeveloper as shown in attachments can you help me please?

Claude Moore wrote:And welcome to the ranch !


thanks
Screenshot_10.png
[Thumbnail for Screenshot_10.png]
 
Abdullah khaled
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Abdullah khaled wrote:

Dave Tolls wrote:Your method is structured like this:


Now, If an exception other than a SQLException is thrown then you will never know, because you have put a return in the finally clause.  That exception will be lost entirely.

Move the return statement outside the finally block and then you'll see the exception that is happening, and that you are hiding at the moment.




Sorry i've just realized that i set an id for an object that doesn't exist yet, i don't know how to edit my reply so sorry about that
 
Sheriff
Posts: 24635
56
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Abdullah khaled wrote:Sorry i've just realized that i set an id for an object that doesn't exist yet, i don't know how to edit my reply so sorry about that



No problem, it sounds like you have found the source of the NullPointerException? If so, that's great. Otherwise just carry on with the discussion here on this thread.
 
Proudly marching to the beat of a different kettle of fish... while reading this tiny ad
Java file APIs (DOC, XLS, PDF, and many more)
https://products.aspose.com/total/java
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!