title: If I use a singleton class for a database connection, can one user close the connection for everybody?
body: <p>I wrote a singleton class for obtaining a database connection.</p>
  
  <p>Now my question is this: assume that there are 100 users accessing the application. If one user closes the connection, for the other 99 users will the connection be closed or not?</p>
  
  <p>This is my sample program which uses a singleton class for getting a database connection:</p>
  
  <pre><code>public class GetConnection {
  
      private GetConnection() { }
  
      public Connection getConnection() {
          Context ctx = new InitialContext();
          DataSource ds = ctx.lookup("jndifordbconc");
          Connection con = ds.getConnection();
          return con;
      }
  
      public static  GetConnection   getInstancetoGetConnection () {
          // which gives GetConnection class instance to call getConnection() on this .
      }
  }
  </code></pre>
  
  <p>Please guide me.</p>