private String QUERY = "(SELECT * FROM tab1 WHERE year = ? and month = ?) UNION (SELECT * FROM tab2 WHERE year = ? and month = ?) UNION (SELECT * FROM tab3 WHERE year = ? and month = ?");
aPreparedStatement = connection.prepareStatement(QUERY);
aPreparedStatement.setString(1, "2012");
aPreparedStatement.setString(2, "july");
aPreparedStatement.setString(3, "2012");
aPreparedStatement.setString(4, "2012");
aPreparedStatement.setString(5, "july");
aPreparedStatement.setString(6, "2012");
而不是一次又一次地设置“?” 相同的参数,有什么方法可以避免使用多个 setString 方法来替换 PreparedStatement 中的相同参数?