/*
 * Copyright 2017 Joao Antonio.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package BibliotecaCompartilhada;
import static BibliotecaCompartilhada.Biblioteca.enderecos;
import static BibliotecaCompartilhada.Biblioteca.telefones;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.SQLException;

/**
 *
 * @author Joao Antonio
 */
public class LeitorDao {
    // a conexão com o banco de dados
    private Connection connection;
    public LeitorDao() {
        this.connection = new ConnectionFactory().getConnection();
    }
    public void adiciona(Leitor leitor) {
        String sql = "insert into leitor " +
            "(nomeLeitor,CPFLeitor,emailLeitor,interesseLeitor,enderecoLeitor,telefoneLeitor)" +
            " values (?,?,?,?,?,?)";
        try ( // prepared statement para inserção
                PreparedStatement stmt = connection.prepareStatement(sql)) {
            // seta os valores
            stmt.setString(1,leitor.getNomeLeitor());
            stmt.setString(2,leitor.getCPFLeitor());
            stmt.setString(3,leitor.getEmailLeitor());
            stmt.setString(4,leitor.getInteresseLeitor());
            stmt.setInt(5,enderecos.get(leitor.getEnderecoLeitor().getCodigoEndereco()));
            stmt.setInt(6,telefones.get(leitor.getTelefoneLeitor().getCodigoTelefone()));
            // executa
            stmt.execute();
        }
        catch (SQLException e) {
            throw new RuntimeException(e);
        }
    }
}
@@ -1152,33 +1152,16 @@
  leitor 
-%22 +%0A            %22
 (nomeLei
@@ -1186,16 +1186,37 @@
 lLeitor,
+%22%0A                + %22
 interess
@@ -1307,16 +1307,28 @@
    try (
+%0A           
  // prep
@@ -1356,20 +1356,16 @@
 nser%C3%A7%C3%A3o%0A
-    
         
@@ -1711,22 +1711,8 @@
 t(5,
-enderecos.get(
 leit
@@ -1754,17 +1754,16 @@
 ereco())
-)
 ;%0A      
@@ -1786,22 +1786,8 @@
 t(6,
-telefones.get(
 leit
@@ -1829,17 +1829,16 @@
 efone())
-)
 ;%0A      

Update LeitorDao.java