Java Eclipse Swing: Error compiling an already functional method

0

Eclipse does not allow me to run my application since it launches the following:

  

Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException       at Conexion.LlenadoCombo (Conexion.java:177)

public void LlenadoCombo(JComboBox CBEntradas){
    rs=Consulta("select * from informativo");
    try{
        while(rs.next()){
            CBEntradas.addItem(rs.getString("idInformativo")+": "+rs.getString("asunto"));
        }
    }catch(SQLException e){
        JOptionPane.showMessageDialog(null, e.getMessage());
    }
}

The error is marked on line 4 while(rs.next()){

It is a method of filling items String to JComboBox from a SQL Server database, I have not had any error in the connection and I have a connection locally so I discard an error of that origin . I had previously compiled , the error came after adding a line of code in another event of the main class. However, this line of code does not use any of the variables of this method nor does it modify any important attribute of the main class.

Any solution or is it an Eclipse bug?

    
asked by Luis Fernando Robles 14.11.2016 в 12:58
source

1 answer

0

Is the error via joptionpane or does the app stop you? I ask because if you know that, you can know where the error is, if you crashed, you know it's here: rs = Query ("select * from informativo");

rs what is it?

I recommend you to do unit testing with JUnit to save you this kind of problems, greetings!

    
answered by 14.11.2016 / 15:12
source