Package br.inatel.ec.ac308.agenda.dao

Source Code of br.inatel.ec.ac308.agenda.dao.PessoaJuridicaDAO

package br.inatel.ec.ac308.agenda.dao;

import br.inatel.ec.ac308.agenda.dados.Contato;
import br.inatel.ec.ac308.agenda.dados.PessoaFisica;
import br.inatel.ec.ac308.agenda.dados.PessoaJuridica;
import br.inatel.ec.ac308.agenda.dao.ConnectionFactory;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;

public class PessoaJuridicaDAO {

    private final Connection connection;

    public PessoaJuridicaDAO() {
        this.connection = new ConnectionFactory().getConnection();
    }

    public void adicionaContato(Contato contato) {
        String sql = "insert into contato "
                + "(nome,endereco,telefone)"
                + " values (?,?,?)";
        try {
            PreparedStatement stmt = connection.prepareStatement(sql);

            stmt.setString(1, contato.getNome());
            stmt.setString(2, contato.getEndereco());
            stmt.setString(3, contato.getTelefone());
            stmt.execute();
            stmt.close();
        } catch (SQLException e) {
            throw new RuntimeException(e);
        }
    }

   

}
TOP

Related Classes of br.inatel.ec.ac308.agenda.dao.PessoaJuridicaDAO

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.