0
Guys, I created a method within a class that searches RS in the database, it works perfectly, but when I use it in another class, it does not do what you want, see the method:
    public void preencherArrayCidades(ArrayList acidades) throws SQLException{  
con = Conectar ();
 String sqlStmt = "SELECT * FROM Trabalho01.cidades ORDER BY nome_cidade";  
 PreparedStatement stmt =con.prepareStatement(sqlStmt);
 ResultSet rs = stmt.executeQuery();
 stmt.execute(); 
    ArrayList cidades = new ArrayList(); 
 while(rs.next()){  
cidades.add(rs.getInt("id_cidade"));
}  
}
To get these values, I’m using this code:
    CidadeController cidadecontroller = new CidadeController();
Cidade cidade = new Cidade();
 ArrayList cidades = new ArrayList(); 
        try {
           cidadecontroller.preencherArrayCidades(cidades);
        } catch (SQLException ex) {
            Logger.getLogger(CidadeView.class.getName()).log(Level.SEVERE, null, ex);
        }
        JOptionPane.showMessageDialog(rootPane, cidades);