I’m trying to pass values from my SQL database to fill a table but I’m getting no data back

  java, mysql, phpmyadmin

I simply want to fill a table with data from my SQL database that I created with phpMyAdmin. I’ll share an image of my database.

I’m completely perplex as to what my problem is, I have a try catch to return me an error message if anything goes wrong but i’m not getting anything back. I know the problem isn’t my conection because I have another table that I was able to fill with data.

I simplied copy and pasted and changed the values, but my new table isn’t getting any data.

My table name is jTable_Inv. This is the first time I have a problem like this.
Heres an image of my database.

enter image description here

And heres my code:

public class GestionInventario extends javax.swing.JFrame {
DefaultTableModel model = new DefaultTableModel();
/**
 * Creates new form GestionInventario
 */
public GestionInventario() {
    initComponents();
    initComponents();
    setSize(600, 450);
    setResizable(false);
    setLocationRelativeTo(null);
    
    setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
    try {            
        Connection cn = Conexion.conectar();           
        PreparedStatement pst = cn.prepareStatement(
        "select Id_inventario, Disponible, Pelicula from inventario");
        
            ResultSet rs = pst.executeQuery();
            
            jTable_Inv = new JTable(model);
            jScrollPane1.setViewportView(jTable_Inv);
            
            model.addColumn(" ");
            model.addColumn("Disponibles");
            model.addColumn("Pelicula");
           
            while(rs.next()) {
                Object [] fila = new Object[3];
                for (int i = 0; i<3; i++){
                    fila[i] = rs.getObject(i + 1);
                }
                model.addRow(fila);                   
            }             
            cn.close();
            
    } catch (SQLException e) {
        System.err.println("Error en el llenado de la tabla");
    }
}

Source: PHPMYADMIN

LEAVE A COMMENT