• 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
  • Bear Bibeault
  • Jeanne Boyarsky
  • paul wheaton
Sheriffs:
  • Junilu Lacar
  • Paul Clapham
  • Knute Snortum
Saloon Keepers:
  • Stephan van Hulst
  • Ron McLeod
  • Tim Moores
  • salvin francis
  • Carey Brown
Bartenders:
  • Tim Holloway
  • Frits Walraven
  • Vijitha Kumara

While loop broke while retrieving data.  RSS feed

 
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]
 
Rancher
Posts: 3983
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: 1114
36
IBM DB2 Java Netbeans IDE Spring
  • 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: 24288
55
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.
 
I'm a lumberjack and I'm okay, I sleep all night and work all day. Lumberjack ad:
global solutions you can do at home or in your backyard
https://www.kickstarter.com/projects/paulwheaton/better-world-boo
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!