This week's giveaway is in the EJB and other Java EE Technologies forum.
We're giving away four copies of EJB 3 in Action and have Debu Panda, Reza Rahman, Ryan Cuprak, and Michael Remijan on-line!
See this thread for details.
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 EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Databases » JDBC
Bookmark "Resultset Problem" Watch "Resultset Problem" New topic
Author

Resultset Problem

Raosaheb Patil
Greenhorn

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
Bartender

Joined: Oct 29, 2001
Posts: 8705
    
    6

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.


"blabbing like a narcissistic fool with a superiority complex" ~ N.A.
[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!
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
 
subject: Resultset Problem
 
Similar Threads
SQL: howto retrieve only the first row?
Result Set .Code check please
SQL stmt Not working
delete & select subquery.. giving me tough time.. plz hlep
Query Preparation