title: Java Database Connection Sharing in Multiple Threads
body: <p>I am calling my db connection method inside every single thread (using ExecutorService for fixed thread pooling) but if I am not using syncrhonized on the <code>getConnection</code> method then it is giving me error that </p>
  
  <blockquote>
    <p>the connection has been closed</p>
  </blockquote>
  
  <p>I am new to multi-threading so  I read the Oracle document for <code>DriverManager.getConnection()</code>  and it says that </p>
  
  <blockquote>
    <p>"The DriverManager.getConnection() method returns a new Java
    Connection object every time you call it. Note that although the
    method is not creating a new physical connection (only a single
    implicit connection is used), it is returning a new object."</p>
  </blockquote>
  
  <p>If I am already passing new <code>Connection</code> object in each worker thread then how come connection is getting closed.  </p>