This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.

Bug 206349 - Debugger Problem with resultset of postgresql
Summary: Debugger Problem with resultset of postgresql
Status: RESOLVED INCOMPLETE
Alias: None
Product: debugger
Classification: Unclassified
Component: Java (show other bugs)
Version: 7.0.1
Hardware: Other Windows 7 x64
: P1 normal (vote)
Assignee: Martin Entlicher
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-12-14 02:02 UTC by lserkeis
Modified: 2012-01-10 13:28 UTC (History)
0 users

See Also:
Issue Type: DEFECT
Exception Reporter:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description lserkeis 2011-12-14 02:02:56 UTC
Product Version = NetBeans IDE 7.0.1 (Build 201107282000)
Operating System = Windows 7 version 6.1 running on amd64
Java; VM; Vendor = 1.6.0_24
Runtime = Java HotSpot(TM) 64-Bit Server VM 19.1-b02

Hi, i`m having a problem with the debugger of netbeans.
Everytime when ii use the debug mode, the resultset of a prepared statement always returns false, but when i don`t use debug mode, it works...
I need some help
Thanks
Comment 1 Jiri Kovalsky 2011-12-14 07:22:48 UTC
This is too little information Leonardo. Can you prepare a small project reproducing the problem for us? What is that statement? Can you attach a screenshot of the problem?
Comment 2 lserkeis 2011-12-14 14:53:57 UTC
(In reply to comment #1)
> This is too little information Leonardo. Can you prepare a small project
> reproducing the problem for us? What is that statement? Can you attach a
> screenshot of the problem?


Of course, and thanks for answer!

So, i can't take a screenshot because the code is too large...
But, here is the code:

    public List<Encomenda> consultarEncomendasEmAberto(){
        
        List<Encomenda> listaEncomendas = new ArrayList<Encomenda>();
        
        ResultSet rs = null;
        PreparedStatement ps = null;
        Connection con = null;
        
            try {
                
                con = Conexao.conectarBanco();
                
                StringBuilder sql = new StringBuilder(); 
                
                sql.append(" SELECT *");
                sql.append(" FROM tb_encomenda");
                sql.append(" WHERE status = ?");
                
                ps = con.prepareStatement(String.valueOf(sql));
                ps.setInt(1, 1);
                
                rs = ps.executeQuery();
                
                if(!rs.next())
                {
                    JOptionPane.showMessageDialog(null, "Não existem encomendas no momento.", "Erro", 0);
                } else {

                    Encomenda encomenda = new Encomenda();
                    encomenda.setCliente(pesquisarCliente(rs.getString("cpf_cli")));
                    encomenda.setFuncionario(Conexao.buscarFuncionario(rs.getString("cpf_func")));
                    encomenda.setProtocolo(rs.getInt("protocolo"));
                    encomenda.setDescricao(rs.getString("descricao"));
                    listaEncomendas.add(encomenda);
                    
                    while(rs.next())
                    {
                        Encomenda e = new Encomenda();
                        e.setCliente(pesquisarCliente(rs.getString("cpf_cli")));
                        e.setFuncionario(Conexao.buscarFuncionario(rs.getString("cpf_func")));
                        e.setProtocolo(rs.getInt("protocolo"));
                        e.setDescricao(rs.getString("descricao"));
                        listaEncomendas.add(e);
                    }
                }                
                
            } catch (Exception e) {
                Logger.getLogger(TelaLogin.class.getName()).log(Level.SEVERE, null, e);
            } finally {
                if(rs != null)
                    try { rs.close(); } catch (Exception e) { }
                if(ps != null)
                    try { ps.close(); } catch (Exception e) { }
                if(con != null)
                    try { con.close(); } catch (Exception e) { }
            }        
        
        
        return listaEncomendas;
    }


The ResultSet always returns false, already on the first time when i call rs.next(). Ps.: (Only when i'm debugging, otherwise, when just running, the resultset works O.O")

Do you understood? (Sorry my bad conversation :( )

Thanks!!
Comment 3 Martin Entlicher 2011-12-15 13:55:15 UTC
What do you mean by "the resultset of a prepared statement always returns false"?
Do you mean that "rs.next()" is false under the debugger, but true during normal execution?
If it is so, aren't you calling "rs.next()" in the debugger? For instance by a conditional breakpoint, or by a watch, etc.? rs.next() moves the cursor froward one row, therefore it's explicit invocation by debugger would alter the state of the application.
If this is not the case, can you compare the execution under the debugger and without debugger in a more detail? E.g. test what rs.isLast() returns, etc.