Granny's Programming Pearls
"inside of every large program is a small program struggling to get out"
JavaRanch.com/granny.jsp
  • 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
  • Junilu Lacar
  • Martin Vashko
Sheriffs:
  • Jeanne Boyarsky
  • Tim Cooke
  • Knute Snortum
Saloon Keepers:
  • Ron McLeod
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
Bartenders:
  • Scott Selikoff
  • salvin francis
  • Piet Souris

Help with "is either not in any table in the FROM list" - error

 
Ranch Hand
Posts: 99
2
Netbeans IDE PHP Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Best, ranchers!

I have encountered a huge problem. I have an application that is connected to a derby database. I populate my form objects with methods like the one below



The method in question have worked fine until suddenly I received the following error message



I know since earlier that theese errors can occur when you do not put quotes around variables in a query, but here i use parameters so I can't see what goes wrong with the query in question. This is how affected table structure looks like



Oh, a note, I have my tables stored in text files where each line is delimeted with a ";" - mark. I would be very greatful for any kind of help or hint.

Thanks a lot in advance to anyone who has taken time to read this post.

Best regards,
Robert!
 
Saloon Keeper
Posts: 6456
61
Eclipse IDE Firefox Browser MySQL Database VI Editor Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Can you print or log your sql string? Are you sure the table you are passing in has a 'lang' column?

I find this messy to read
would have preferred this


 
Robert Ingmarsson
Ranch Hand
Posts: 99
2
Netbeans IDE PHP Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Best, Mr. Brown!

I haven't got a clue on what's going on here with my select statement. The tables are created through a method that parses textfiles so I am pretty sure that the table in this question "tbl_language" really is there. The table has three columns, "id"-column", "name"-column and one "lang"-column.

I have adopted your suggested code change. I agree it was a little bit tricky to read, sorry. I am not sure though what you are meaning with "print or log your sql string" ?

Best regards,
Robert!
 
Carey Brown
Saloon Keeper
Posts: 6456
61
Eclipse IDE Firefox Browser MySQL Database VI Editor Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
 
Carey Brown
Saloon Keeper
Posts: 6456
61
Eclipse IDE Firefox Browser MySQL Database VI Editor Java Windows
 
Robert Ingmarsson
Ranch Hand
Posts: 99
2
Netbeans IDE PHP Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ok, now I understand. Well, I logged my sql string as follows



And it gave me the following result:



I hote that was the correct answer to your question.

Robert!
 
Robert Ingmarsson
Ranch Hand
Posts: 99
2
Netbeans IDE PHP Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Best, Mr. Brown!

I think I have found out what the problem is. I have tried to read the values from a table that hasn't the lang column in its field list.
Thats why the tbl_agerating showed up in the sql log string, and that table only has a name column. What a miss! I have
to change this right away.

Terribly sorry for this and thank you so much for your kind replies!  

Best regards,
Robert!
 
Carey Brown
Saloon Keeper
Posts: 6456
61
Eclipse IDE Firefox Browser MySQL Database VI Editor Java Windows
 
Robert Ingmarsson
Ranch Hand
Posts: 99
2
Netbeans IDE PHP Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi!

The schema for tbl_agerating should be the default schema, "APP".

This is the method I used to fix the problem, no parameters in the sql string!



Regards,
Robert!
 
Carey Brown
Saloon Keeper
Posts: 6456
61
Eclipse IDE Firefox Browser MySQL Database VI Editor Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Just an FYI: Your close statements should be in the reverse order that the resources were opened in. So, you've got them backwards. 'rs' was the last resource to be opened/created, so it should be the first to be closed().
 
Master Rancher
Posts: 4370
47
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
More importantly you should be using a try-with-resources for them, as any one might throw an exception preventing the others from being closed:

That way you don't need to worry about closing them as Java will handle that, and you don't need to worry about ordering either.
 
Whose rules are you playing by? This tiny ad doesn't respect those rules:
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!