title: java.sql.Connection not visible from within a thread
body: <p>I created one thread with java.sql.Connection and String parameters. 
  But from within the thread, I observed that String value was available but Connection object was not. Any clues?</p>
  
  <p>(Editing details into question):</p>
  
  <p>Well, it seems the connection object is available, but closed inside the thread.
  Here's the code:</p>
  
  <pre><code>package com.catgen.helper;
  
  import java.sql.Connection;
  
  public class ImageCheckHelper extends Thread{
  
      public Connection conn = null;
      public String str = null;
  
      public ImageCheckHelper(Connection conn, String str){
          this.conn = conn;
          this.str = str;
          try{
              System.out.println("From inside the constructor");
              System.out.println((this.conn!=null)?"Connection is not null":"Connection is null");
              System.out.println((this.str!=null)?"String is not null":"String is null");
              System.out.println((this.conn.isClosed())?"Connection is closed.":"Connection is not closed");
              System.out.println("\n\n");
          }catch(Exception e){
              e.printStackTrace();
          }
      }
  
      public void run(){
          try{
              System.out.println("From inside the thread");
              System.out.println((conn!=null)?"Connection is not null":"Connection is null");
              System.out.println((str!=null)?"String is not null":"String is null");
              System.out.println((conn.isClosed())?"Connection is closed.":"Connection is not closed");
          }catch(Exception e){
              e.printStackTrace();
          }
      }
  
      public void initiateImageCheck(){
          this.start();
          return;
      }
  }
  </code></pre>
  
  <p>And here's the output:</p>
  
  <pre><code>From inside the constructor
  Connection is not null
  String is not null
  Connection is not closed
  
  
  
  From inside the thread
  Connection is not null
  String is not null
  Connection is closed.
  </code></pre>