Solucionado (ver solución)
Solucionado
(ver solución)
3
respuestas

[Duda] carga informacion pero no sale mensaje de registro exitoso

Buenas noches

por favor me pueden apoyar. la información que ingreso en la tabla si se esta sumando pero cuando doy clic en el boton de guardar no me aparece el mensaje de registro exitoso, pero cuando vuelvo y lanzo el programa me aparece la nueva linea.

Ingrese aquí la descripción de esta imagen para ayudar con la accesibilidad

3 respuestas

Hola Jeisson, ¡espero que estés bien!

¿Podría mostrar lo que aparece en la consola?

Y mostrar también cómo está el código referente al botón mencionado.

¡Saludos y buenos estudios!

Hola, si claro

este es el error que me aparece en consola, mas abajo te coloco el codigo del boton guardar

Exception in thread "AWT-EventQueue-0" java.lang.RuntimeException: java.sql.SQLException: After end of result set
    at com.alura.jdbc.view.ControlDeStockFrame.guardar(ControlDeStockFrame.java:261)
    at com.alura.jdbc.view.ControlDeStockFrame$1.actionPerformed(ControlDeStockFrame.java:133)
    at java.desktop/javax.swing.AbstractButton.fireActionPerformed(AbstractButton.java:1972)
    at java.desktop/javax.swing.AbstractButton$Handler.actionPerformed(AbstractButton.java:2313)
    at java.desktop/javax.swing.DefaultButtonModel.fireActionPerformed(DefaultButtonModel.java:405)
    at java.desktop/javax.swing.DefaultButtonModel.setPressed(DefaultButtonModel.java:262)
    at java.desktop/javax.swing.plaf.basic.BasicButtonListener.mouseReleased(BasicButtonListener.java:279)
    at java.desktop/java.awt.Component.processMouseEvent(Component.java:6620)
    at java.desktop/javax.swing.JComponent.processMouseEvent(JComponent.java:3398)
    at java.desktop/java.awt.Component.processEvent(Component.java:6385)
    at java.desktop/java.awt.Container.processEvent(Container.java:2266)
    at java.desktop/java.awt.Component.dispatchEventImpl(Component.java:4995)
    at java.desktop/java.awt.Container.dispatchEventImpl(Container.java:2324)
    at java.desktop/java.awt.Component.dispatchEvent(Component.java:4827)
    at java.desktop/java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:4948)
    at java.desktop/java.awt.LightweightDispatcher.processMouseEvent(Container.java:4575)
    at java.desktop/java.awt.LightweightDispatcher.dispatchEvent(Container.java:4516)
    at java.desktop/java.awt.Container.dispatchEventImpl(Container.java:2310)
    at java.desktop/java.awt.Window.dispatchEventImpl(Window.java:2780)
    at java.desktop/java.awt.Component.dispatchEvent(Component.java:4827)
    at java.desktop/java.awt.EventQueue.dispatchEventImpl(EventQueue.java:775)
    at java.desktop/java.awt.EventQueue$4.run(EventQueue.java:720)
    at java.desktop/java.awt.EventQueue$4.run(EventQueue.java:714)
    at java.base/java.security.AccessController.doPrivileged(AccessController.java:399)
    at java.base/java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:86)
    at java.base/java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:97)
    at java.desktop/java.awt.EventQueue$5.run(EventQueue.java:747)
    at java.desktop/java.awt.EventQueue$5.run(EventQueue.java:745)
    at java.base/java.security.AccessController.doPrivileged(AccessController.java:399)
    at java.base/java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:86)
    at java.desktop/java.awt.EventQueue.dispatchEvent(EventQueue.java:744)
    at java.desktop/java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:203)
    at java.desktop/java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:124)
    at java.desktop/java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:113)
    at java.desktop/java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:109)
    at java.desktop/java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:101)
    at java.desktop/java.awt.EventDispatchThread.run(EventDispatchThread.java:90)
Caused by: java.sql.SQLException: After end of result set
    at com.mysql.cj.jdbc.exceptions.SQLError.createSQLException(SQLError.java:129)
    at com.mysql.cj.jdbc.exceptions.SQLError.createSQLException(SQLError.java:97)
    at com.mysql.cj.jdbc.exceptions.SQLError.createSQLException(SQLError.java:89)
    at com.mysql.cj.jdbc.exceptions.SQLError.createSQLException(SQLError.java:63)
    at com.mysql.cj.jdbc.result.ResultSetImpl.checkRowPos(ResultSetImpl.java:517)
    at com.mysql.cj.jdbc.result.ResultSetImpl.getObject(ResultSetImpl.java:1314)
    at com.mysql.cj.jdbc.result.ResultSetImpl.getInt(ResultSetImpl.java:822)
    at com.alura.jdbc.controller.ProductoController.guardar(ProductoController.java:74)
    at com.alura.jdbc.view.ControlDeStockFrame.guardar(ControlDeStockFrame.java:259)
    ... 36 more
 public void guardar(Map<String, String> producto) throws SQLException {
        Connection con = new ConnectionFactory().recuperaConexion();
        Statement statement = (Statement) con.createStatement();

        statement.execute("INSERT INTO PRODUCTO(nombre, descripción, cantidad)"
                + " VALUES ('" + producto.get("NOMBRE") + "','"
                + producto.get("DESCRIPCIÓN") + "'," 
                + producto.get("CANTIDAD") + ")",
                Statement.RETURN_GENERATED_KEYS);


        ResultSet resulset = ((java.sql.Statement) statement).getGeneratedKeys();

        while(resulset.next());{
            System.out.println(
                    String.format(
                            "Fue insertado el producto de Id ",
                            resulset.getInt(1)));
        }



    }

}
solución!

Hola Brenda,

ya encontre el error, tenia un punto y coma de mas en el while.

Ingrese aquí la descripción de esta imagen para ayudar con la accesibilidad