• 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:
  • Liutauras Vilda
  • Campbell Ritchie
  • Tim Cooke
  • Bear Bibeault
  • Devaka Cooray
Sheriffs:
  • Jeanne Boyarsky
  • Knute Snortum
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Ganesh Patekar
  • Stephan van Hulst
  • Pete Letkeman
  • Carey Brown
Bartenders:
  • Tim Holloway
  • Ron McLeod
  • Vijitha Kumara

ResultSet problem  RSS feed

 
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi guys,
i am new to this forum....i have got some problem with conditional SELECT statement while working with JDBC.Following is my code fragment.


the loop (while(rst1.next()) is not working that is it is not retriving values form the table "teacherdata" which is pointed by "project".please help

[edited to add code tags to preserve formatting]
[ April 11, 2005: Message edited by: Jeanne Boyarsky ]
 
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Instead of using SELECT *
Specify your columns. Then retrive them our of the result set using the column name.
 
Indranil Guha Roy
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
thanks for reply...but if u could be more specific about the syntax of SELECT statement (i.e how to use column names to retrive data), it would have been more helpfull.
 
Ranch Hand
Posts: 1085
Java Oracle Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Indranil,

you should have posted this in JDBC Forum.
any way does the query printed by System.out.println(query1) gives you result.
If yes then make sure you are connected to correct database or check if there is any exception you are ignoring.

Shailesh
 
author
Sheriff
Posts: 14112
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Indranil accidentally posted this in a new thread:

Originally posted by Indranil Guha Roy:
thanks for reply...but if u could be more specific about the syntax of SELECT statement (i.e how to use column names to retrive data), it would have been more helpfull.



Anyway, moving to JDBC...
 
Heath Williams
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Try this:


Do it for each column you need.
 
Ranch Hand
Posts: 1141
1
Java Oracle
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Indranil,
If your query is not returning any rows, it means you are supplying a "code" that does not exist in the TEACHERDATA table. (Or have I misunderstood your problem?)

In other words, perhaps the problem is with your SQL (and not with your java).

Good Luck,
Avi.
 
Ranch Hand
Posts: 405
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I agree:


If your query is not returning any rows, it means you are supplying a "code" that does not exist in the TEACHERDATA table. (Or have I misunderstood your problem?)

In other words, perhaps the problem is with your SQL (and not with your java)



How about removing the space after and before your single qoute from ' input ' field. i.e.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!