Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 4 of 4

Thread: Why rs...still connected

  1. #1
    Junior Member
    Join Date
    Jan 2011
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Why rs...still connected

    Hi, pls helo when i closed the windows, why the rs not closed as the OUPUT still show"still connected"

    addWindowListener(new WindowAdapter()
             {  @Override
                public void windowClosing(WindowEvent e)
                    {try {
                        con.close();
                        stmt.close();
                        rs.close();
                        System.out.println(rs+" will be closing");
                        if(rs != null)
                        System.out.println(rs+" still connected");
                        System.exit(0);
                    } catch (SQLException ex) {
                        Logger.getLogger(ResultSetFrame.class.getName()).log(Level.SEVERE, null, ex);
                    }
                    }


  2. #2
    Forum Squatter newbie's Avatar
    Join Date
    Nov 2010
    Location
    North Wales
    Posts
    661
    My Mood
    Stressed
    Thanks
    28
    Thanked 115 Times in 106 Posts
    Blog Entries
    1

    Default Re: Why rs...still connected

    I'm no expert when it comes to this area but could you provide your code where you initialise your Connection, Statement and ResultSet Objects in case you're pooling the connection, though it's just a stab in the dark.
    Please use [highlight=Java]//code goes here...[/highlight] tags when posting your code

  3. #3
    Administrator copeg's Avatar
    Join Date
    Oct 2009
    Location
    US
    Posts
    5,296
    Thanks
    180
    Thanked 824 Times in 767 Posts
    Blog Entries
    5

    Default Re: Why rs...still connected

    The logic in the code snippet does not evaluate the status of the connection, it evaluates if rs is null (calling close on a stream/resultset/etc...does not nullify the object reference).

  4. #4
    Member DavidFongs's Avatar
    Join Date
    Oct 2010
    Location
    Minneapolis, MN
    Posts
    107
    Thanks
    1
    Thanked 45 Times in 41 Posts

    Default Re: Why rs...still connected

    And if it was null, you would never make it to that null check, because a NullPointerException would be thrown when you called close()

Similar Threads

  1. Replies: 6
    Last Post: July 16th, 2013, 04:21 AM
  2. How to Find machines connected to a network
    By JavaPF in forum Java Networking Tutorials
    Replies: 1
    Last Post: June 18th, 2011, 08:47 AM
  3. calling a java a class connected to derby from a batch file
    By Reem in forum What's Wrong With My Code?
    Replies: 4
    Last Post: October 31st, 2010, 03:01 PM