【发布时间】:2012-09-05 14:32:27
【问题描述】:
我在 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列。
【问题讨论】:
-
cod_cliente和descuento是两列还是一列?在您的字符串中,它们 似乎 是一列(没有逗号),但这意味着您只有 11 个而不是 12 个。 -
谢谢,正因为如此。
标签: java mysql sql prepared-statement