Visualizzazione dei risultati da 1 a 2 su 2
  1. #1

    [JAVA] ERRORE: Parametri insufficienti previsto 35

    Ciao a tutti,

    oggi vi sto stressando, ma mi sono bloccato in un errore che non avevo mai visto e non riesco a capire completamente quale è il problema, dato che comunque i dati e i parametri sembrano essere inseriti ognuno al posto suo.

    Vi posto il codice:

    codice:
    public void modifica_U(String codicef) throws FileNotFoundException{
            File foto1 = this.foto;
            File documento1 = this.documento;
            String s = codicef;
            String query;
            ResultSet rs = null;
            try{
                String driver = "sun.jdbc.odbc.JdbcOdbcDriver";
                Class.forName(driver);
                String url = "jdbc:odbc:MY_DATA2";
                Connection con = DriverManager.getConnection(url, "username", "password");
                query = "UPDATE Arb2 SET nome=?, cognome=?, codiceF=?, causale=?, protcollo=?, arch=?, dataNascita=?, luogoNascita=?, dataRichiesta=?, NBadge=? , pG=?, pC=?, pD=?, pP=?, V01=?,V02=?,V04=?,V05=?,V06=?,V07=?,V08=?,V10=?,V11=?,V12=?,V13=?, colore=?, dataScadenza=?, foto=?, documento=?, nomeFoto=?, nomeDocumento=?, ricervuta=? WHERE codiceF=?";
                PreparedStatement cmd = con.prepareStatement(query);
                  cmd.setString(1, this.nome);
                  cmd.setString(2, this.cognome);
                  cmd.setString(3, this.codiceF);
                  cmd.setString(4, this.causale);
                  cmd.setString(5, this.protocollo);
                  cmd.setString(6, this.arch);
                  cmd.setString(7, this.dataNascita);
                  cmd.setString(8, this.luogoNascita);
                  cmd.setString(9, this.dataRichiesta);
                  cmd.setString(10, this.nBadge);
                  cmd.setString(11, this.pG);
                  cmd.setString(12, this.pC);
                  cmd.setString(13, this.pD);
                  cmd.setString(14, this.pP);
                  cmd.setString(15, this.V01);
                  cmd.setString(16, this.V02);
                  cmd.setString(17, this.V04);
                  cmd.setString(18, this.V05);
                  cmd.setString(19, this.V06);
                  cmd.setString(20, this.V07);
                  cmd.setString(21, this.V08);
                  cmd.setString(22, this.V10);
                  cmd.setString(23, this.V11);
                  cmd.setString(24, this.V12);
                  cmd.setString(25, this.V13);
                  cmd.setString(26, this.colore);
                  cmd.setString(27, this.dataScadenza);
                  //FOTO
                  InputStream fin = new java.io.FileInputStream(foto1);
                  int fileLength = (int)foto1.length();
                  cmd.setBinaryStream(28, fin, fileLength);
                  //DOCUMENTO
                  fin = new java.io.FileInputStream(documento1);
                  fileLength = (int)documento1.length();
                  cmd.setBinaryStream(29, fin, fileLength);
                  cmd.setString(30, foto1.getName());
                  cmd.setString(31, documento1.getName());
                  cmd.setString(32, this.ricevuta);
                  cmd.setString(33, s);
                  cmd.executeUpdate();
            }catch(SQLException | ClassNotFoundException e){
                e.printStackTrace();
            }
        }
    Gli unici due campi in più che si trovano all'interno della tabella sul quale non effettuo alcune operazioni, sono il primo che contiene la chiave primaria con un intero progressivo e un altro.

    Questo è il messaggio di errore che mi restituisce:

    codice:
    java.sql.SQLException: [Microsoft][Driver ODBC Microsoft Access] Parametri insufficienti. Previsto 35.
        at sun.jdbc.odbc.JdbcOdbc.createSQLException(Unknown Source)
        at sun.jdbc.odbc.JdbcOdbc.standardError(Unknown Source)
        at sun.jdbc.odbc.JdbcOdbc.SQLParamData(Unknown Source)
        at sun.jdbc.odbc.JdbcOdbcPreparedStatement.execute(Unknown Source)
        at sun.jdbc.odbc.JdbcOdbcPreparedStatement.executeUpdate(Unknown Source)
        at ARB2.Gestione.modifica_U(Gestione.java:303)
        at ARB2.Gui$8.actionPerformed(Gui.java:1174)
        at javax.swing.AbstractButton.fireActionPerformed(Unknown Source)
        at javax.swing.AbstractButton$Handler.actionPerformed(Unknown Source)
        at javax.swing.DefaultButtonModel.fireActionPerformed(Unknown Source)
        at javax.swing.DefaultButtonModel.setPressed(Unknown Source)
        at javax.swing.plaf.basic.BasicButtonListener.mouseReleased(Unknown Source)
        at java.awt.Component.processMouseEvent(Unknown Source)
        at javax.swing.JComponent.processMouseEvent(Unknown Source)
        at java.awt.Component.processEvent(Unknown Source)
        at java.awt.Container.processEvent(Unknown Source)
        at java.awt.Component.dispatchEventImpl(Unknown Source)
        at java.awt.Container.dispatchEventImpl(Unknown Source)
        at java.awt.Component.dispatchEvent(Unknown Source)
        at java.awt.LightweightDispatcher.retargetMouseEvent(Unknown Source)
        at java.awt.LightweightDispatcher.processMouseEvent(Unknown Source)
        at java.awt.LightweightDispatcher.dispatchEvent(Unknown Source)
        at java.awt.Container.dispatchEventImpl(Unknown Source)
        at java.awt.Window.dispatchEventImpl(Unknown Source)
        at java.awt.Component.dispatchEvent(Unknown Source)
        at java.awt.EventQueue.dispatchEventImpl(Unknown Source)
        at java.awt.EventQueue.access$200(Unknown Source)
        at java.awt.EventQueue$3.run(Unknown Source)
        at java.awt.EventQueue$3.run(Unknown Source)
        at java.security.AccessController.doPrivileged(Native Method)
        at java.security.ProtectionDomain$1.doIntersectionPrivilege(Unknown Source)
        at java.security.ProtectionDomain$1.doIntersectionPrivilege(Unknown Source)
        at java.awt.EventQueue$4.run(Unknown Source)
        at java.awt.EventQueue$4.run(Unknown Source)
        at java.security.AccessController.doPrivileged(Native Method)
        at java.security.ProtectionDomain$1.doIntersectionPrivilege(Unknown Source)
        at java.awt.EventQueue.dispatchEvent(Unknown Source)
        at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source)
        at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)
        at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
        at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
        at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
        at java.awt.EventDispatchThread.run(Unknown Source)
    Qualcuno mi sa dire cosa sto sbagliando??

    Grazie!!

  2. #2
    Ho risolto il problema, in pratica era un discorso di database, fra i campi "dataScadenza" e "foto" vi era un campo vuoto chiamato richiesta, questo campo era uno dei due campi sul quale non mi interessava effettuare operazioni, ho semplicemente spostato la tabella del campo alla fine del database e il programma non mi ha dato più errore e adesso completa l'operazione.

    Spero possa aiutare qualcuno.

Permessi di invio

  • Non puoi inserire discussioni
  • Non puoi inserire repliche
  • Non puoi inserire allegati
  • Non puoi modificare i tuoi messaggi
  •  
Powered by vBulletin® Version 4.2.1
Copyright © 2025 vBulletin Solutions, Inc. All rights reserved.