1
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’ll get the idHistorico and the idProduto, but I also wanted to get the name and price, which is in the other table produtos. I can add to the try another Select?
Yes, you can do.
– gmsantos