这是用于使用Java和Derby的家庭作业。
以下编译并运行正常,但我的编译器并不高兴。
String getTotalWeightFromSingleYear = "SELECT SUM(weight) as total_weight From Hive where YEAR(harvestdate) = ? ORDER BY total_weight";
PreparedStatement psGetTotalWeightFromSingleYear = connection.prepareStatement(getTotalWeightFromSingleYear);
psGetTotalWeightFromSingleYear.setInt(1, rs.getInt("just_year"));
resultSet = psGetTotalWeightFromSingleYear.executeQuery();
resultSet.next();
IDE报告它无法解析参数查询1,我认为它阻止了查询的ORDER BY部分运行。使用内置YEAR功能时,我可以使用预准备语句吗?如果是这样,怎么做。