1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36
|
String num=request.getParameter("txtnum");
int n=Integer.parseInt(num);
PreparedStatement stmt = null;
//String sql = "select * from personne where nom like '?'";
String sql = "select * from personne where code=?";
try {
stmt = conn.prepareStatement(sql);
//stmt.setString(1, nom);
stmt.setInt(1, n);
ResultSet rs = stmt.executeQuery();
while (rs.next()) {
...
}
} catch (SQLException e) {
logger.error("ça marche pas", e);
} finally {
if (rset != null) {
try {
rset.close();
}
catch (Exception e) {
logger.warn("resultset pas fermé", e);
}
}
if (stmt != null) {
try {
stmt.close();
}
catch (Exception e) {
logger.warn("statement pas fermé", e);
}
}
} |