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
| public static JTable chercherlivre(String isbnlivre){
String requete=null;
try{
requete="SELECT * FROM `bdjavacagou`.`livre` WHERE `bdjavacagou`.`livre`.`ISBN` = '"+isbnlivre+"'";
stmt=cc.createStatement();
ResultSet res=stmt.executeQuery(requete);
System.out.println(res.toString());
ResultSetMetaData infores=res.getMetaData();
for (int i=1;i <=infores.getColumnCount();i++)
{
nomColonnes.add(infores.getColumnLabel(i));}
while(res.next()){
Vector<String> ligne = new Vector<String>();
for(int i=1;i<=infores.getColumnCount();i++){
String champ=res.getString(i);
ligne.add(champ); }
tabligne.addAll(ligne);
}
res.close();
stmt.close();
}
catch (SQLException e){
JOptionPane.showMessageDialog(null,"problème lors de recherche vérifier votre ISBN","",
JOptionPane.ERROR_MESSAGE);
}
return new JTable(tabligne,nomColonnes);
} |
Partager