我一直在努力解决这个问题,似乎无法找到解决办法。
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
每当我尝试运行代码时,都会收到一个耗尽的resultSet错误。它应该打印出所有列的完整表,它可以正常工作。我唯一的问题是与之相似
System.out.println("Statistics for " + rs1.getString(2) + " By Spencer");
我尝试将这行代码放入if(rs1.next())但条件永远不会为真,所以它只是完全跳过这一行。我完全难过,并且会喜欢一些帮助。
我的Sql视图
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;