I have a small problem when performing an INSERT TO A DATABASE THAT BELIEVES IN MY SQL THROUGH SCRIPT IN NETBEANS. MY COLLABORATOR TABLE HAS 31 FIELDS, EH CREATED 31 TextField to receive the information written there, and yet when I click on the button to do the function, I see this error.
by the way, I leave the code that you enter in the button that I use to perform the function of recording in the database:
private void btnSiguienteMouseClicked(java.awt.event.MouseEvent evt) {
frmEducacion abrirFrmEdu = new frmEducacion();
abrirFrmEdu.setVisible(true);
try {
// aqui se guardaran los campos ingresados
PreparedStatement pst = cn.prepareStatement("INSERT INTO Colaborador (DniColaborador,Apellido ,Nombre ,Edad ,Sexo , " +
"LugarTrabajoAsig,GerenciaAsig," +
"JefaturaAsig ,Puesto ,FechNacimiento ,DistritoNaci,ProvinciaNaci,DepartNaci" +
"PaisNaci ,TelfFijo,Celular,Email ,EstadoCivil,DirecDomicilio ,RefeDomicilio," +
"TipoCategoria,NroBrevete,FechaVencimiento,CentroAsisEssalud,SNPAFP,GrupoSanguineo," +
"TallaCamisa,TallaPantalon,NroCalzado,Estatura,Peso) VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)");
pst.setString(1, txtDniColaborador.getText());
pst.setString(2, txtApellido.getText());
pst.setString(3, txtNombre.getText());
pst.setString(4, txtEdad.getText());
pst.setString(5, txtSexo.getText());
pst.setString(6, txtLugarTrabajo.getText());
pst.setString(7, txtGerencia.getText());
pst.setString(8, txtJefatura.getText());
pst.setString(9, txtPuesto.getText());
pst.setString(10, txtFechaNacimiento.getText());
pst.setString(11, txtDistritoColab.getText());
pst.setString(12, txtProvinciaColab.getText());
pst.setString(13, txtDepartamentoColab.getText());
pst.setString(14, txtPais.getText());
pst.setString(15, txtTelfFijo.getText());
pst.setString(16, txtCelular.getText());
pst.setString(17, txtEmail.getText());
pst.setString(18, txtEstadoCivil.getText());
pst.setString(19, txtDomicilio.getText());
pst.setString(20, txtRefUbicacion.getText());
pst.setString(21, txtTipoCategoria.getText());
pst.setString(22, txtNroBrevete.getText());
pst.setString(23, txtFechaVencimiento.getText());
pst.setString(24, txtEssalud.getText());
pst.setString(25, txtSNPAFP.getText());
pst.setString(26, txtGrupoSanguineo.getText());
pst.setString(27, txtTallaCamisa.getText());
pst.setString(28, txtTallaPantalon.getText());
pst.setString(29, txtNroCalzado.getText());
pst.setString(30, txtEstatura.getText());
pst.setString(31, txtPeso.getText());
pst.execute();
JOptionPane.showMessageDialog(null, "Se acaban de guardar los Datos Generales del Colaborador");
this.setVisible(false);
} catch (Exception e) {
JOptionPane.showMessageDialog(null, "ERROR : " + e);
}
}
and here is my script to create my table in mysql:
drop table if exists Colaborador;
create table Colaborador(
DniColaborador VARCHAR(50) NOT NULL,
Apellido VARCHAR(50) NOT NULL,
Nombre VARCHAR(50) NOT NULL,
Edad VARCHAR(2) NOT NULL,
Sexo VARCHAR(1) NOT NULL,
LugarTrabajoAsig VARCHAR(50) NOT NULL,
GerenciaAsig VARCHAR(50) NOT NULL,
JefaturaAsig VARCHAR(50) NOT NULL,
Puesto VARCHAR(50) NOT NULL,
FechNacimiento VARCHAR(12) NOT NULL, --
DistritoNaci VARCHAR(50) NOT NULL,
ProvinciaNaci VARCHAR(50) NOT NULL,
DepartNaci VARCHAR(50) NOT NULL,
PaisNaci VARCHAR(50) NOT NULL,
TelfFijo VARCHAR (9) NOT NULL,
Celular VARCHAR(9) NOT NULL,
Email VARCHAR(50) NOT NULL,
EstadoCivil VARCHAR(12) NOT NULL,
DirecDomicilio VARCHAR(50) NOT NULL,
RefeDomicilio VARCHAR(50) NOT NULL,
TipoCategoria VARCHAR(10) NOT NULL,
NroBrevete VARCHAR(9) NOT NULL,
FechaVencimiento VARCHAR(12) NOT NULL, --
CentroAsisEssalud VARCHAR(50) NOT NULL,
SNPAFP VARCHAR(50) NOT NULL,
GrupoSanguineo VARCHAR(5) NOT NULL,
TallaCamisa VARCHAR(4) NOT NULL,
TallaPantalon VARCHAR(2) NOT NULL,
NroCalzado VARCHAR(2) NOT NULL,
Estatura VARCHAR(4) NOT NULL,
Peso VARCHAR(3) NOT NULL,
PRIMARY KEY(DniColaborador)
);
I repeat, it has 31 fields exactly my COLLABORATOR table. So I do not understand why I get that problem since everything fits: /