File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes JDBC and the fly likes ResultSet problem Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Soft Skills this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Databases » JDBC
Bookmark "ResultSet problem" Watch "ResultSet problem" New topic
Author

ResultSet problem

Indranil Guha Roy
Greenhorn

Joined: Apr 11, 2005
Posts: 6
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

Joined: Jan 22, 2004
Posts: 6
Instead of using SELECT *
Specify your columns. Then retrive them our of the result set using the column name.


Heath Williams
Indranil Guha Roy
Greenhorn

Joined: Apr 11, 2005
Posts: 6
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

Joined: Aug 13, 2004
Posts: 1081

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


Gravitation cannot be held responsible for people falling in love ~ Albert Einstein
Ilja Preuss
author
Sheriff

Joined: Jul 11, 2001
Posts: 14112
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...


The soul is dyed the color of its thoughts. Think only on those things that are in line with your principles and can bear the light of day. The content of your character is your choice. Day by day, what you do is who you become. Your integrity is your destiny - it is the light that guides your way. - Heraclitus
Heath Williams
Greenhorn

Joined: Jan 22, 2004
Posts: 6
Try this:


Do it for each column you need.
Avi Abrami
Ranch Hand

Joined: Oct 11, 2000
Posts: 1135

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

Joined: Mar 19, 2002
Posts: 405
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.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: ResultSet problem