This week's book giveaway is in the XML and Related Technologies forum.
We're giving away four copies of Java XML & JSON and have Jeff Friesen on-line!
See this thread for details.
Win a copy of Java XML & JSON this week in the XML and Related Technologies forum!
  • 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
  • Devaka Cooray
  • Jeanne Boyarsky
  • Bear Bibeault
Sheriffs:
  • Junilu Lacar
  • Paul Clapham
  • Knute Snortum
Saloon Keepers:
  • Ron McLeod
  • Tim Moores
  • Stephan van Hulst
  • salvin francis
  • Carey Brown
Bartenders:
  • Tim Holloway
  • Frits Walraven
  • Ganesh Patekar

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]
 
Master Rancher
Posts: 3887
45
  • 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: 1088
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: 24074
54
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.
 
All of the world's problems can be solved in a garden - Geoff Lawton. Tiny ad:
RavenDB is an Open Source NoSQL Database that’s fully transactional (ACID) across your database
https://coderanch.com/t/704633/RavenDB-Open-Source-NoSQL-Database
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!