在文档中找不到。
java ResultSet是否支持查询参数,例如jdbcTemplate?
例如:
int length = 10;
ResultSet rs = stmt.executeQuery("select MyTable.COLOR from MyTable where MyTable.LENGTH = ?", new Object[] { length });
有可能吗?
谢谢。
答案 0 :(得分:5)
PreparedStatement
允许(编号)参数:
PreparedStatement pstmt = connection.prepareStatement(
"select MyTable.COLOR from MyTable where MyTable.LENGTH=?");
pstmt.setInt(1, desiredLength);
ResultSet rs = pstmt.executeQuery();