Java insert查询中preparedStatement的问题

Java insert查询中preparedStatement的问题,java,mysql,sql,prepared-statement,Java,Mysql,Sql,Prepared Statement,我在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)"+

我在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:列计数与第1行的值计数不匹配,为什么


自动递增的列显然不在这里,因此没有它,它们是12列。

您的名字中有11个字段,但有12个问号


第一行末尾可能缺少一个

您的姓名中有11个字段,但有12个问号


第一行末尾可能缺少一个

您只有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)

您只有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)

您发布的错误很明显,您列出的列名与
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("+             
            "?,?,?,?,?,?,?,?,?,?,?,?);";

您发布的错误很明显,您列出的列名与
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("+             
            "?,?,?,?,?,?,?,?,?,?,?,?);";

cod\u客户
descunto
是两个独立的列,还是一个列?在您的字符串中,它们似乎是一列(没有逗号),但这意味着您只有11列,而不是12列。谢谢,正因为如此。是
cod\u cliente
descumento
两个单独的列,还是一列?在您的字符串中,它们似乎是一列(没有逗号),但这意味着您只有11列,而不是12列。谢谢,这就是原因。