-1
I’m creating a graph that pulls data from the database, but at the time of generating the graph gives the following error:
Exception in thread "AWT-Eventqueue-0" java.lang.Nullpointerexception
The first line you accuse in error is within the method createDataset (is the first line inside the "of". That is the method:
private XYDataset createDataset(){
    XYSeries series = new XYSeries("Teste");
    conex.conectar();
    try{
    do{
        double rcv = conex.rs.getDouble("rcv_arena_verde"); 
        double rth = conex.rs.getDouble("rth_arena_verde"); 
    series.add(rcv, rth);
    } while (conex.rs.next());
    }catch (SQLException ex){ 
        JOptionPane.showMessageDialog(null, "Erro ao preencher grafico \n " +ex.getMessage());
    }
    XYSeriesCollection dataset = new XYSeriesCollection();
    dataset.addSeries(series); 
    return dataset;
} 
The methods/parameters of connection with the bank are correct, after all I use them in other classes in the same project and I have no problems. Am I using/calling them incorrectly? I have tried several things and the error persists.
EDIT
Other parts of the class for a better understanding of it:
public class GraficosArenaProceso extends javax.swing.JFrame {
ConexaoBanco conex = new ConexaoBanco();
ModeloBeansPruebasArenaEnVerde mod = new ModeloBeansPruebasArenaEnVerde();
DaoPruebasArenaEnVerde control = new DaoPruebasArenaEnVerde();
 public GraficosArenaProceso() {
    initComponents();
    initUI();
}
   private void initUI(){
    XYDataset dataset = createDataset();
    JFreeChart chart = createChart(dataset);
    ChartPanel chartPanel = new ChartPanel(chart);
    // [...] Aspectos visuais do gráfico           
}
Main method:
    public static void main(String args[]) {
    SwingUtilities.invokeLater(() -> {
        GraficosArenaProceso graficoProceso = new GraficosArenaProceso();
        graficoProceso.setVisible(true);
    } );
Note that conex is not null, but conex.rs is. This object may not have been created correctly.
– user158926
Actually Fabius, the "conex.rs" was not initialized. How should I do this? I understood the concept behind having to start the conex.rs, after all it is really null, but I lost myself in the correct way to initialize it.
– Leonardo Buzzi