嗨,我对这段代码有疑问,因为它似乎总是返回 SQL 异常。它工作了几次然后停止并异常返回。所以我不确定出了什么问题。我曾尝试将 vld.close() 更改为不同的地方,所以是的。谢谢
PreparedStatement vld = conn.prepareStatement("SELECT * FROM carsharing.available(?,?,?,?)");
vld.setString(1, carName);
vld.setString(2, memberUser);
vld.setTimestamp(3, new java.sql.Timestamp(startTime.getTime()));
vld.setTimestamp(4, new java.sql.Timestamp(endTime.getTime()));
System.out.println("test1");
ResultSet rset = vld.executeQuery();
System.out.println("test2");
rset.next();
int num = rset.getInt("num");
boolean valid = rset.getBoolean("aval");
vld.close();
System.out.println(num);
System.out.println(valid);