Tenho o seguinte código e não consigo descobrir onde se encontra o problema, já desenvolvi todas as outras classes, mas esta falta concluir.
Alguem por gentileza poderia me ajudar?
Mensagem de erro: The method closeConnection(Connection, Statement, ResultSet) in the type Conexao is not applicable for the arguments (Connection,
PreparedStatement, null)
//Implementação
package voluntarios;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import java.util.ArrayList;
import voluntarios.excecoes.WebPersistenciaException;
public class CadastroImpl implements CadastroDAO {
public CadastroDAO registarCadastros(CadastroDTO rDTO)
throws WebPersistenciaException {
Connection conn = Conexao.getInstancia().getConnection();
PreparedStatement pstmt = null;
String sql = "insert into VOLUNTARIOS values(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,"
+"?,?,?,?,?,?,?,?,?,?)";
try {
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, rDTO.getID());
pstmt.setString(2, rDTO.getNome());
pstmt.execute();
} catch (SQLException e){
throw new WebPersistenciaException(e.getMessage());
} finally {
Mensagem de erro: The method closeConnection(Connection, Statement, ResultSet) in the type Conexao is not applicable for the arguments
(Connection, PreparedStatement, null) Para linha seguinte.
Conexao.getInstancia().closeConnection(conn, pstmt, null);
}
return rDTO;
}
public CadastroDTO alterarCadastros(CadastroDTO rDTO){
throws WebPersistenciaException{
Connection conn = Conexao.getInstancia().getConnection();
PreparedStatement pstmt = null;
String sql = "update VOLUNTARIOS set Nome=?, Identidade=?,"
+ "CPF=?, DataCadastro=?, NomeMae=?, DataNascto=?"
+ "Endereco=?, Bairro=?, Cidade=?, FoneContato1=?"
+ "FoneContato2=?, PessoaContato1=?, PessoaContato2=?"
+ "Email1=?, Email2=?, EscolaridadeAtual=?, Curso=?"
+ "InstituicaoEnsino=?, TurnoEA=?, LocalTrab=?"
+ "ProfissaoAtual=?, TurnoP=?, OpcaoTrabVoluntario=?"
+ "OpcaoTrabVoluntDiscip=?"
+ "where ID=?"+;
try {
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, rDTO.getNome());
pstmt.setString(2, rDTO.getID());
pstmt.execute();
} catch (SQLException e){
throw new WebPersistneciaException(e.getMessage());
} finally {
Conexao.getInstancia().closeConection(conn, pstmt, null);
}
return rDTO;
}
public CadastroDTO excluirCadastros(CadastroDTO rDTO){
throws WebPersistenciaException {
Connection conn = Conexao.getInstancia().getConnection();
PreparedStatement pstmt = null;
String sql = "delete from VOLUNTARIOS where ID=?";
try {
pstmt = conn.prepareStatement();
pstmt.setString(1, rDTO.getID());
pstmt.execute();
} catch (SQLException e){
throw new WebPersistenciaException(e.getMessage());
} finally {
Conexao.getInstancia().closeConnection(conn, pstmt, null);
}
return rDTO;
}
public String recuperaCadastro(CadastroDTO rDTO){
throws WebPersistenciaException{
Connection conn = Conexao.getInstancia().getConnection();
PreparedStatement pstmt = null;
ResultSet rs = null;
String sql = "select id from VOLUNTARIOS where id=?";
try {
pstmt = conn.preparedStatement(sql);
pstmt.setString(1, rDTO.getID());
rs = pstmt.executeQuery();
if (rs.next()) {
return rs.getString("ID");
}
} catch (SQLException e){
throw new WebPersistenciaException(e.getMessage());
} finally {
Conexao.getInstancia().closeConnection(conn, pstmt, null);
}
return "";
}
}
public ArrayList imprimiCadastros() throws WebPersistenciaException{
Connection conn = null;
Statement stmt = null;
ResultSet rs = null;
ArrayList lista = new ArrayList();
String sql = "select * from VOLUNTARIOS order by nome";
try {
conn = Conexao.getInstancia().getConnection();
stmt = conn.createStatement();
rs = stmt.executeQuery();
while (rs.next()){
lista.add(new CadastroDTO(rs.getString(1), rs.getString(2)));
}
} catch (SQLException e){
throw new WebPersistenciaException(e.getMessage());
} finally {
Conexao.getInstancia().closeConnection(conn, stmt, rs);
}
return lista;
}
}