ResulSet retornando Null

Quando executo o metodo getByFilter() ele me retorna com erro de NullPointerException. Não vejo nada de errado na classe.

public class PessoaDAO extends DALTemplate<Pessoa> {


    public PessoaDAO() { 
	super();
    }	

    protected String getSelectQuery(){
	return "Select * From Pessoa";
    }

    protected String getDeleteQuery(){
	return "Delete From Pessoa Where id = ?";
    }

    protected String getInsertQuery(){
	return "Insert Into Pessoa (nome, idade) Values (?,?) ";
    }

    protected String getUpdateQuery(){
	return "Update Pessoa Set nome = ?, idade = ? Where id = ?";
    } 
   

    protected boolean insert(Pessoa value) throws Exception
    {
        try
        {            
            this.setCommand(this.getConnection().prepareStatement(this.getInsertQuery()));
            this.setParameters(value);

            if(this.getCommand().executeUpdate() > 0)      
               return true;           
        }
        catch(Exception ex)
        { 
            throw new Exception("Erro ao inserir Pessoa.");
        }
        finally
        {
            this.getCommand().close();
            this.getConnection().close();
        }
        return false;
    }

    

    protected boolean update(Pessoa value) throws Exception
    {
      try
      {             
            this.setCommand(this.getConnection().prepareStatement(getUpdateQuery()));
	    this.setParameters(value);
 

            if(this.getCommand().executeUpdate() > 0)       
               return true;           
        }
        catch(Exception ex)
        { 
            throw new Exception("Erro ao atualizar Pessoa.");          
        }
        finally
        {
            this.getCommand().close();
            this.getConnection().close();
        }
        return false;
    }



    public boolean delete(Pessoa value) throws Exception {
        try
        {
            this.setCommand(this.getConnection().prepareStatement(getDeleteQuery()));
            this.getCommand().setInt(1, value.getId());
             
            if(this.getCommand().executeUpdate() > 0)
                return true;           
        }
        catch(Exception ex)
        { 
            throw new Exception("Erro ao deletar Pessoa."); 
        }
        finally
        {
            this.getCommand().close();
            this.getConnection().close();
        }
        return false;
    }


    public Collection<Pessoa> getByIdade(int idade) throws Exception{
               
        try                
        {       
            String query = this.getSelectQuery() + " Where idade = ?";   
            this.setCommand(this.getConnection().prepareStatement(query));   
            this.getCommand().setInt(1, idade);
            
            return super.convertToCollection(this.getCommand().executeQuery());


        }
        catch(Exception ex)
        {
            throw new Exception("Erro ao obter Pessoas do sistema.");
        }
        finally
        {
            this.getCommand().close();
            this.getConnection().close();
        }
    }



    public Pessoa getByFilter(int id) throws Exception{
         ResultSet resultSet = null;
        
        try                
        {       
            String query = this.getSelectQuery() + " Where id = ?";            
            this.setCommand(this.getConnection().prepareStatement(query));  
            
            this.getCommand().setInt(1, id);
            resultSet = this.getCommand().executeQuery();
            
            if(resultSet.next()){
                return this.convert(resultSet);  
            }
            return null;
        }
        catch(Exception ex)
        {
            throw new Exception("Erro ao obter Pessoa por id.");
        }
        finally
        {
            resultSet.close();
            this.getCommand().close();
            this.getConnection().close();
        }
        
        
    }



    protected Pessoa convert(ResultSet resultSet) throws Exception
    {
        try
        {
            Pessoa pessoa = new Pessoa();
            
            pessoa.setId(resultSet.getInt("id"));
            pessoa.setNome(resultSet.getString("nome"));
            pessoa.setIdade(resultSet.getInt("idade"));
                         
            return pessoa;
        }
        catch(Exception ex)
        {
            throw new Exception("Erro ao preencher Pessoa.");
        }
    }  

    protected void setParameters(Pessoa value) throws Exception
    {   	
    	try
        {
        	this.getCommand().setString(1, value.getNome());
            this.getCommand().setInt(2, value.getIdade());         
        }
        catch(Exception ex)
        {
            throw new Exception("Erro ao preencher parametros.");
        }
    }   
}

Boa noite Colegas !

Onde estão os métodos getCommand e setCommand ?

[]s

[quote=Zeed01]Boa noite Colegas !

Onde estão os métodos getCommand e setCommand ?

[]s[/quote]

Estão na classe ConnectionDAL, que é herdada pela classe DALTemplate que é herdada por essa classe.

public abstract class ConnectionDAL{
    
    private String connectionString;
    private Connection connection;
    private PreparedStatement command; 
    
    public ConnectionDAL() {
    	// Conexao para banco Access
        this.Init("jdbc:odbc:Driver={Microsoft Access Driver (*.mdb)};DBQ=C:\\PessoaDb.mdb");
    }
        
    public void Init(String connectionString) 
    {
        try
        {
            DriverManager.registerDriver(new sun.jdbc.odbc.JdbcOdbcDriver());
            this.setConnectionString(connectionString);    
            this.setConnection(DriverManager.getConnection(this.getConnectionString())); 
        }
        catch(Exception ex)
        {            
        }
    }

    public String getConnectionString() {
        return connectionString;
    }

    public void setConnectionString(String connectionString) {
        this.connectionString = connectionString;
    }

    public Connection getConnection() {
       
         try {
                if(connection == null)                
                    connection = DriverManager.getConnection(this.getConnectionString());        
                 return connection;
        } catch (SQLException ex) {
            ex.printStackTrace();
        }  
         return null;       
    }

    public void setConnection(Connection connection) {
        this.connection = connection;
    }

    public PreparedStatement getCommand() {
        return command;
    }

    public void setCommand(PreparedStatement command) {
        this.command = command;
    }
}

Já pensou em usar um depurador (debbuger)?

Geralmente é o jeito mais fácil de achar problemas como esse. Principalmente pq o StackTrace já te dá a linha que o erro aconteceu, então fica fácil parar no ponto certo e analisar o problema.

[quote=ViniGodoy]Já pensou em usar um depurador (debbuger)?

Geralmente é o jeito mais fácil de achar problemas como esse. Principalmente pq o StackTrace já te dá a linha que o erro aconteceu, então fica fácil parar no ponto certo e analisar o problema.[/quote]

Usei o printStackTrace() e da esse erro:

java.sql.SQLException: General error
at sun.jdbc.odbc.JdbcOdbc.throwGenericSQLException(Unknown Source)
at sun.jdbc.odbc.JdbcOdbc.SQLAllocStmt(Unknown Source)
at sun.jdbc.odbc.JdbcOdbcConnection.prepareStatement(Unknown Source)
at sun.jdbc.odbc.JdbcOdbcConnection.prepareStatement(Unknown Source)
at DataAccessLayer.PessoaDAO.getByFilter(PessoaDAO.java:133)
at BussinessLogicLayer.PessoaBLL.obterPorID(PessoaBLL.java:36)
at main.Main.main(Main.java:32)

Ok, agora ponha um breakpoint na linha 133 do método getFilter (que você já deveria ter destacado qual é, logo no seu primeiro post) e com o depurador veja o valor de cada uma das variáveis e retornos de método daquela linha.

A que tiver o valor “null”, bingo! É o seu problema.