my dog learned polymorphism
The moose likes JDBC and Relational Databases and the fly likes Resultset Problem Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Databases » JDBC and Relational Databases
Bookmark "Resultset Problem" Watch "Resultset Problem" New topic

Resultset Problem

Raosaheb Patil

Joined: Jan 07, 2004
Posts: 6
Please check the following Code. Am I missing something?
It gives runtime error with "result.getInt("FY")".But if we substitute
the real Values it works fine...

SelStmt= "Select t1.* "
+ "from program t1, quarter t2 "
+ "where (t1.fy=t2.fy and t1.quarter= t2.quarter) and activity_grp_code='PA'";

stmt = con.prepareStatement(SelStmt);
bFlag = stmt.execute();

result = stmt.getResultSet();
max = stmt.getMaxRows();
String Seltmpsql;
ResultSet SeltmpResult;
boolean tmpFlag;
PreparedStatement Seltmpstmt = null;
Seltmpsql="Select sdate,edate from quarter "
+"Where" + result.getInt("FY");
Joe Ess

Joined: Oct 29, 2001
Posts: 9189

It would really help if you would print the message and the stack trace of the exception you are getting. I can take a wild stab at it and point you to the documentation for java.sql.ResultSet:

A ResultSet object maintains a cursor pointing to its current row of data. Initially the cursor is positioned before the first row. The next method moves the cursor to the next row, and because it returns false when there are no more rows in the ResultSet object, it can be used in a while loop to iterate through the result set.

[How To Ask Questions On JavaRanch]
Jason Steele
Ranch Hand

Joined: Apr 25, 2003
Posts: 100
You have a syntax error in your sql statement:

Seltmpsql="Select sdate,edate from quarter "
+"Where" + result.getInt("FY");

Your WHERE clause is missing a comparator. I think you want:
Seltmpsql="SELECT sdate,edate FROM quarter WHERE fy = " + result.getInt("fy");
Good Luck!

An egg is a chicken's house!
I agree. Here's the link:
subject: Resultset Problem
It's not a secret anymore!