• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Pblm with code plz help

 
Raghu NeoN
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
public Vector squery(){
Vector vs= new Vector();

String sql2="SELECT * FROM st_ship_d ;";
try{
ResultSet Rs1=state1.executeQuery(sql2);
Vcctor vs= new Vector();
while(Rs1.next()){
vs.addElement(Rs1.getString(3));
System.out.println(Rs1.getString(3));
}
}
catch(Exception e){
System.out.println(e);
}
return vs;
}
this is code where i am tryin to connect to database(Acess) to fetch recoreds.the prblm is the prigramm is fetchin only one row frm the database. after fetchin one record it says "java.sql Exception : No data Found"
connection is opened and 3 is the column index no.
any suggestions, i ma new to jdbc..
pls help
thanks in advance
 
Paul Caudle
Ranch Hand
Posts: 64
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This is a common problem with that darn ResultSet, apparently. I am not sure if they have fixed it for Java 1.2, but I know that the 1.1 ResultSet does not hold data permanently. Once you use the method getString(int) or getString(String), it literally removes the value for good so that you can only access it once. I would suggest, if you need to use this object again soon, attaching a reference to it, String s = Rs1.getString(3), and then using the reference (s) to add it to the Vector and print it out.
I hope that helps.
-Paul
[This message has been edited by Paul Caudle (edited June 15, 2000).]
 
Raghu NeoN
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
yeah i got it paul..
thnks for ur help....
will be back soon with other question
take care
------------------
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic