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
|
Connection connection = null;
PreparedStatement pstmt = null;
try
{
connection = DBUtils.getConnection();
pstmt = connection.prepareStatement("select ... from nomTable where id=? and type=?");
pstmt.setInt(1, maValeurDeCle);
pstmt.setString(2, monType);
ResultSet rs = pstmt.executeQuery();
while ( rs.next() )
{
int c1 = rs.getInt("nomColonneInt");
String c2 = rs.getString("nomColonneString");
...
}
}
catch (Throwable t)
{
...
}
finally
{
if ( pstmt != null ) pstmt.close();
if ( connection != null ) connection.close();
} |