File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes JDBC and Relational Databases and the fly likes Invalid cursor state 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 "Invalid cursor state " Watch "Invalid cursor state " New topic

Invalid cursor state

nabou diack

Joined: Oct 17, 2001
Posts: 13
Hi do you know how to solve the invalid cursor state error I am getting on this code.
I am actually trying to do a query inside another query. thanks for your help
public synchronized Vector getafacturer( Remote handle) throws java.rmi.RemoteException
Statement st2 = initTransaction(handle);

if(st2 != null)
clientInfos client = getClientInfosFromHandle(handle);
if( (client.classLevel == ADMINISTRATOR) | | (client.classLevel == SUPERVISOR) )
String query1, query2;
//Vector list2 = new Vector();
Vector afacturerlist2 = new Vector();

/* query1 = " SELECT * FROM ListeProjet";*/

query2= " SELECT NoProjet, Expr1 FROM heurestravaillees";

System.out.println("SQL: " + query2);
ResultSet rs2 = st2.executeQuery(query2);
//infos.heurestravaillees= rs2.getDouble("Expr1");
//ajoute les factures a la liste
afacturerinfos infos = new afacturerinfos();

infos.noprojet = rs2.getString("NoProjet");
Long noproj = new Long (infos.noprojet);
infos.heurestravaillees= rs2.getDouble("Expr1");

query1 = "SELECT DISTINCT Facture.NoProjet, Sum(FactureDetail.HeuresFacture) AS Sumhf " +
"FROM Facture INNER JOIN FactureDetail ON Facture.NoFacture = FactureDetail.NoFacture " +
"WHERE Facture.NoProjet =" +noproj+
" GROUP BY Facture.NoProjet";

System.out.println("SQL: " + query1);
ResultSet rs3 = st2.executeQuery(query1);
infos.heuresfacturees= rs3.getDouble("Sumhf");

return afacturerlist2;
catch (Exception e){e.printStackTrace();}
return null;
I agree. Here's the link:
subject: Invalid cursor state
It's not a secret anymore!