PostulanteDao.java 1.59 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
package Postulante;
import com.roshka.proyectofinal.Postulante;

import java.util.*;
import java.sql.*;

public class PostulanteDao {

    public static Connection getConnection(){
        Connection con=null;
        try{
            Class.forName("oracle.jdbc.driver.OracleDriver");
            con=DriverManager.getConnection("jdbc:oracle:thin:@localhost:1521:xe","system","oracle");
        }catch(Exception e){System.out.println(e);}
        return con;
    }
    public static int save(Postulante postulante){
        int status=0;
        try{
20
            Connection con=PostulanteDao.getConnection();
21
            PreparedStatement ps=con.prepareStatement(
22
                    "insert into postulante(nombre,apellido,nro_cedula,correo,telefono,direccion,experiencia_laboral,estudio_universitario,notebook,bootcamp_id,aceptado) values (?,?,?,?,?,?,?,?,?,?,?)");
23 24 25
            ps.setString(1,postulante.getNombre());
            ps.setString(2,postulante.getApellido());
            ps.setInt(3,postulante.getNro_cedula());
26 27 28 29 30 31 32 33
            ps.setString(4,postulante.getCorreo());
            ps.setString(5,postulante.getTelefono());
            ps.setString(6,postulante.getDireccion());
            ps.setBoolean(7,postulante.getExpLaboral());
            ps.setBoolean(8,postulante.getEstudioUniversitario());
            ps.setBoolean(9,postulante.getNotebook());
            ps.setInt(10,postulante.getBootcampId());
            ps.setBoolean(11,postulante.getAceptado());
34 35 36 37 38 39 40 41 42

            status=ps.executeUpdate();

            con.close();
        }catch(Exception ex){ex.printStackTrace();}

        return status;
    }
}