String checkAvailable_flight = String.format("SELECT Flightid, flightdate,"
+ " origin, destination FROM flight"
+ " WHERE Flightdate::Date = %s AND origin = %s"
+ " AND destination = %s;", date_, origin_, destination_);
ResultSet rs = stmt.executeQuery(checkAvailable_flight);
if (!rs.next()) {
System.out.println("no data inserted");
} else {
do {
int flightid = rs.getInt("flightid");
String date = rs.getString("flightdate");
String origin = rs.getString("origin");
String destination = rs.getString("destination");
System.out.printf("%-10d %5s %5s %7s\n",flightid, date, origin, destination);
} while (rs.next());
}
发生错误:
SQLException : ERROR: operator does not exist: date = integer
Hint: No operator matches the given name and argument type(s). You might need to add explicit type casts.
Position: 86
SQLState : 42883
SQLCode : 0
你好,我在 JDBC 上工作,想执行 sql 查询并打印出表格..但我得到了上面的错误..
我尝试以另一种方式投射飞行日期,例如:
CAST(Flightdate AS TEXT) LIKE '2013-04-12%'
但错误仍然发生....
任何建议都会不胜感激..