0

私はMySQLデータベースに13列のテーブルを持っています。最初の列は自動インクリメントで、残りは通常です。私はこれを持っています:

    SQL="INSERT INTO cuentas (id_proveedor_cloud,id_esquema_asociado,id_tipo_cuenta,n_cuenta,nombre_cuenta,cod_cliente"+ 
            "descuento,f_creacion,borrado,f_borrado,id_cuenta_ccis,logo)"+
            " VALUES("+             
            "?,?,?,?,?,?,?,?,?,?,?,?);";

            this.pstm = this.conexion.prepareStatement(SQL);
            this.pstm.setInt(1, proveedor);
            this.pstm.setInt(2, esquema);
            this.pstm.setInt(3, cuenta.getNivel());
            this.pstm.setString(4,num_c);
            this.pstm.setString(5, cuenta.getNombre_cuenta());
            this.pstm.setString(6, "");
            this.pstm.setDouble(7, cuenta.getDescuento());
            this.pstm.setString(8,dateFormat.format(cal.getTime()).toString());
            this.pstm.setBoolean(9, cuenta.isBorrado());
            if(cuenta.isBorrado()==false){
               this.pstm.setString(10,null);
            }else{
                this.pstm.setString(10, dateFormat.format(cal.getTime()).toString());
            }
            this.pstm.setInt(11, cuenta.getId_cuenta_padre());
           this.pstm.setBytes(12, cuenta.getLogo());
int ejecutado =  this.pstm.executeUpdate();

次の間違いがあります: java.sql.SQLException: Column count doesn't match value count at row 1、なぜですか?

自動インクリメントの列は明らかにここにはありません。それがなければ、12 列になります。

4

3 に答える 3

3

VALUESあなたが投稿したエラーは非常に明確です。あなたがリストした列名は、句にリストされた値と一致しません。おそらく,、最初の行の最後で を逃したためです。代わりにこれを試してください:

                                           You missed this , here------
                                                                      |
INSERT INTO cuentas (id_proveedor_cloud,id_esquema_asociado,         \|/
                     id_tipo_cuenta,n_cuenta,nombre_cuenta,cod_cliente, 
            descuento,f_creacion,borrado,f_borrado,id_cuenta_ccis,logo
VALUES("+             
            "?,?,?,?,?,?,?,?,?,?,?,?);";
于 2012-09-05T14:35:38.580 に答える
1

名前には 11 個のフィールドがありますが、疑問符は 12 個です。

,おそらく、最初の行の末尾にa がありません。

于 2012-09-05T14:35:12.317 に答える
0

フィールドは 11 個しかありません

cuentas (id_proveedor_cloud,
id_esquema_asociado,
id_tipo_cuenta,
n_cuenta,
nombre_cuenta,
cod_clientedescuento,
f_creacion,
borrado,
f_borrado,
id_cuenta_
ccis,logo)
于 2012-09-05T14:35:28.653 に答える