If someone please know the solution, my problem is that I am handling a servlet driver and I am trying to insert data into the database but it does not insert me says that javalangnullpointer I already debug and if you are bringing me all the variables that I capture in the form.
The strangest thing of all is that if I insert from a main method, that is, I send the direct data to the create method, it inserts me without problem, from This way I send to the create method to test if it is working and so it works.
I do not understand why when I use the form data sending it does not insert me in the table of the database.
package Modelo.EmpleadoDAO;
import Modelo.Conexion;
import Modelo.Interfaces.Obligatorio;
import Modelo.VO.EmpleadoVO;
import java.util.List;
import java.sql.*;
import java.util.ArrayList;
import java.util.logging.Level;
import java.util.logging.Logger;
/**
*
* @author MIGUEL ANGEL
*/
public class EmpleadoDAO implements Obligatorio<EmpleadoVO>
{
// Querys para trabajar sobre la base de datos
// E.create(new EmpleadoVO(147,"Jesus","Angel","Camargo","Vanegas","1245-07-24","1214-12-04","M",22,"casado",1,"avenida","bogota","b",2,"Programador","donatllo","Antonio Casale",3800.000));
private static final String SQL_Insert="INSERT INTO Empleado (Nit,Primer_nombre,Segundo_nombre,Apellido_paterno,Apellido_materno,Fecha_nacimiento,Fecha_ingreso,Genero,Edad,Estado_civil,Numero_hijos,Direccion,Ciudad,Grupo_sanguineo,Experiencia_anos,Profesion,Email,Jefe_inmediato,Sueldo) VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?) ";
private static final String SQL_Delete="DELETE FROM Empleado WHERE Nit = ?";
private static final String SQL_Update="UPDATE Empleado SET Primer_nombre = ?,Segundo_nombre=?,Apellido_paterno = ?,Apellido_materno = ?,Grupo_sanguineo = ?,Estado_civil = ?,Numero_hijos = ?,Email = ?,Edad = ?,Fecha_ingreso = ?,Jefe_inmediato = ?,Experiencia_anos = ?,Sueldo = ?,Profesion = ?,Genero = ?,Direccion = ?,Ciudad = ? WHERE Nit = ?";
private static final String SQL_Read="SELECT * FROM Empleado WHERE Nit = ?";
private static final String SQL_Readall="SELECT * FROM Empleado";
// private static final String SQL_Insert="INSERT INTO Empleado (Nit) VALUES (?) ";
private static final Conexion con=Conexion.estado();
@Override
public boolean create(EmpleadoVO c)
{
PreparedStatement ps;
try {
ps=con.getConecta().prepareStatement(SQL_Insert);
ps.setInt(1,c.getNit());
ps.setString(2,c.getPrimer_nombre());
ps.setString(3,c.getSegundo_nombre());
ps.setString(4,c.getApellido_paterno());
ps.setString(5,c.getApellido_materno());
ps.setString(6,c.getFecha_nacimiento());
ps.setString(7,c.getFecha_ingreso());
ps.setString(8,c.getGenero());
ps.setInt(9,c.getEdad());
ps.setString(10,c.getEstado_civil());
ps.setInt(11,c.getNumero_hijos());
ps.setString(12,c.getDireccion());
ps.setString(13,c.getCiudad());
ps.setString(14,c.getGrupo_sanguineo());
ps.setInt(15,c.getExperiencia());
ps.setString(16,c.getProfesion());
ps.setString(17,c.getEmail());
ps.setString(18,c.getJefe_inmediato());
ps.setDouble(19,c.getSalario());
if(ps.executeUpdate()>0);
{
return true;
}
} catch (SQLException ex)
{
Logger.getLogger(EmpleadoDAO.class.getName()).log(Level.SEVERE, null, ex);
}finally
{
con.desconectar();
}
return false;
}