Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Resultset Problem

 
Raosaheb Patil
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 9280
10
Linux Mac OS X Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Jason Steele
Ranch Hand
Posts: 100
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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!
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic