1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23
   | 	// Création de la requête SQL et de ses contraintes optionnels :
	SQLBuilder gen = new SQLBuilder("Select * from Vehicule");
	gen.and(!numPlaque.equals(""),	"NUMEROPLAQUE_ID = ?",	numPlaque);
	gen.and(!modele.equals(""),	"MODÈLE = ?",		modele);
	gen.and(!typeCarburant.equals(""),"TYPECARBURANT = ?",	typeCarburant);
	gen.and(Constructeur_id!=0,	"CONSTRUCTEUR_ID = ?",	Constructeur_id);
	gen.and(Client_id!=0,		"CLIENT_ID = ?",	Client_id);
 
	// Création du Statement et exécution de la requête :
	PreparedStatement stmt = gen.createStatement(con);
	try {
		ResultSet rs = stmt.executeQuery();
		try {
			while (rs.next()) {
				// Traitement sur le ResultSet
				// ...
			}
		} finally {
			rs.close();
		}
	} finally {
		stmt.close();
	} | 
Partager