This week's book giveaway is in the OCAJP forum.
We're giving away four copies of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) and have Khalid A Mughal & Rolf W Rasmussen on-line!
See this thread for details.
Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

ResultSet problem

 
Indranil Guha Roy
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 ]
 
Heath Williams
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.
 
Shailesh Chandra
Ranch Hand
Posts: 1082
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
 
Ilja Preuss
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.
 
Avi Abrami
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.
 
Craig Jackson
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic