Menu

wrong in row count at insert

Help
victor
2016-02-17
2016-02-19
  • victor

    victor - 2016-02-17

    Hello everyone!
    I´m trying to insert a row into a table of an Access Database, I´m able to insert into another tables, but whith this one appears an error:

    Información: message to log
    net.ucanaccess.jdbc.UcanaccessSQLException: discrepancia en el número de filas contadas
    at net.ucanaccess.jdbc.UcanaccessConnection.prepareStatement(UcanaccessConnection.java:506)
    at java8.GestorEntradaJava8.insertarEntrada(GestorEntradaJava8.java:30)
    at controller.MenuTopController.initialize(MenuTopController.java:157)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
    at java.lang.reflect.Method.invoke(Unknown Source)
    at sun.reflect.misc.Trampoline.invoke(Unknown Source)
    at sun.reflect.GeneratedMethodAccessor1.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
    at java.lang.reflect.Method.invoke(Unknown Source)
    at sun.reflect.misc.MethodUtil.invoke(Unknown Source)
    at javafx.fxml.FXMLLoader.load(Unknown Source)
    at javafx.fxml.FXMLLoader.load(Unknown Source)
    at javafx.fxml.FXMLLoader.load(Unknown Source)
    at javafx.fxml.FXMLLoader.load(Unknown Source)
    at javafx.fxml.FXMLLoader.load(Unknown Source)
    at javafx.fxml.FXMLLoader.load(Unknown Source)
    at javafx.fxml.FXMLLoader.load(Unknown Source)
    at application.Main.start(Main.java:99)
    at com.sun.javafx.application.LauncherImpl$5.run(Unknown Source)
    at com.sun.javafx.application.PlatformImpl$5.run(Unknown Source)
    at com.sun.javafx.application.PlatformImpl$4$1.run(Unknown Source)
    at com.sun.javafx.application.PlatformImpl$4$1.run(Unknown Source)
    at java.security.AccessController.doPrivileged(Native Method)
    at com.sun.javafx.application.PlatformImpl$4.run(Unknown Source)
    at com.sun.glass.ui.InvokeLaterDispatcher$Future.run(Unknown Source)
    at com.sun.glass.ui.win.WinApplication._runLoop(Native Method)
    at com.sun.glass.ui.win.WinApplication.access$100(Unknown Source)
    at com.sun.glass.ui.win.WinApplication$3$1.run(Unknown Source)
    at java.lang.Thread.run(Unknown Source)

    This is the code:

    iniciarConexion();
        String insertarEntradaSQL = "INSERT INTO " + tabla_Nombre + " VALUES (?,?,?,?,?,?,?,?)";
        PreparedStatement pstmt = conn.prepareStatement(insertarEntradaSQL);
        pstmt.setString(1, ent.getEnNum());
        pstmt.setString(2, ent.getEnFecha());
        pstmt.setString(3, ent.getEnHora());
        pstmt.setInt(4, ent.getEnCamion());
        pstmt.setInt(5, ent.getEnConductor());
        pstmt.setString(6, ent.getEnZona());
        pstmt.setInt(7, ent.getEnPeso());
        pstmt.setBoolean(8, ent.getEnIncidencia());
        pstmt.executeQuery();
    

    I had compact and repaired the table with Access, but it doesn´t solves the problem...

     
  • Gord Thompson

    Gord Thompson - 2016-02-17

    You are trying to use executeQuery() with an INSERT statement, which is incorrect. Use executeUpdate() instead.

     
    • victor

      victor - 2016-02-18

      Returns the same error, but thanks!

       
  • Marco Amadei

    Marco Amadei - 2016-02-18

    It looks like the column number isn't correct.Explicitly declare the column name and order in your statement.

     
    • victor

      victor - 2016-02-18

      Thanks a lot, that was the mistake!!!

       
  • Marco Amadei

    Marco Amadei - 2016-02-18

    Columns are rows when hsqldb is querying table metadata.

     
    • victor

      victor - 2016-02-19

      Ok, it explains the problem

       

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.