I have been struggling with this and I cant seem to find a fix.
public static void doQ(Connection c){
try
{
stmt = c.createStatement();
ResultSet rs1 = stmt.executeQuery("SELECT * FROM VQ1");
ResultSet rs2 = stmt.executeQuery("SELECT * FROM VQ2");
ResultSetMetaData meta = rs2.getMetaData();
System.out.println("");
System.out.println("Statistics for " + rs1.getString(2) + " By Spencer"); // This line recieves the error
System.out.println("");
System.out.println("Orders");
System.out.println("============================================================ =========================");
System.out.printf("%-10s %-10s %11s %12s\n", meta.getColumnName(1), meta.getColumnName(2), meta.getColumnName(3), meta.getColumnName(4));
System.out.println("");
while(rs2.next()){
System.out.printf("%10s %10s %11s %12s\n",rs2.getString(1), rs2.getString(2), rs2.getString(3), rs2.getString(4));
}//end while
rs2.close();
rs1.close();
} catch (SQLException ex){
System.err.println("\nERROR :" + ex.getMessage());
}// end try catch
}//end method
I receive an exhausted resultSet error whenever I try to run my code. It should print out a full table of all the columns which works fine. the only issue i am having is with the like
System.out.println("Statistics for " + rs1.getString(2) + " By Spencer");
I have tried placing this line of code into an if(rs1.next()) but the condition is never true so it just skips the line completely. I'm completely stumped and would love some help.
My Sql Views
DROP VIEW VQ1;
CREATE VIEW VQ1
AS
SELECT COMPANYNAME, TO_CHAR(sysdate, 'dd/mm/yyyy') AS "date"
FROM CUSTOMERS
GROUP BY COMPANYNAME
WITH READ ONLY;
DROP VIEW VQ2;
CREATE VIEW VQ2
AS
SELECT O.ORDERID, TO_CHAR(O.ORDERDATE, 'dd/mm/yyyy') AS "Order date",
NVL2(O.SHIPPEDDATE, 'Shipped', 'Not Shipped') AS "Status",
TO_CHAR(((OD.UNITPRICE * OD.QUANTITY) - (OD.UNITPRICE * OD.QUANTITY * OD.DISCOUNT)), '$999.99') AS "Total"
FROM ORDERS O INNER JOIN ORDERDETAILS OD
ON O.ORDERID = OD.ORDERID
GROUP BY O.ORDERID, TO_CHAR(O.ORDERDATE, 'dd/mm/yyyy'), NVL2(O.SHIPPEDDATE,'Shipped', 'Not Shipped'), TO_CHAR(((OD.UNITPRICE * OD.QUANTITY) - (OD.UNITPRICE * OD.QUANTITY * OD.DISCOUNT)), '$999.99')
WITH READ ONLY;