try {
Connection lig = DriverManager.getConnection("jdbc:mysql://localhost/gym", "root", "0000");
PreparedStatement inst = lig.prepareStatement("SELECT * FROM produtos_has_historico WHERE Produtos_idProdutos AND Historico_idHistorico");
ResultSet a = inst.executeQuery();
while (a.next()){
DefaultListModel model = new DefaultListModel();
model.addElement(a);
}
} catch(Exception e){}
I'm going to get idHistorico
and idProduto
, but I also wanted to get the name and price, which is in the other produtos
table. Can I add to try
other Select
?