title: 5 Different Queries with 5 JDBC Connection Or 5 Different Queries with 1 JDBC Connection.Which is good?
body: <p>I want to know about JDBC Connection use  with respect to <strong>performance</strong>.</p>
  
  <p>E.g
  I want to fetch 5 Different Objects from Database having 5 Different Select Queries to fetch.</p>
  
  <p>I have to options to achieve this.You can also tell another ways.</p>
  
  <p>First One which is Currently I am Using</p>
  
  <pre><code>void fetchSeventObjectMethod(long id1,long id2,.....,long id5) {
  
      1. Open JDBC Connection
  
      2. PrepareStatment 1 
         2.1   Object 1 Fetch Query
         2.1   Bind Object 1 from ResultSet 1
         2.1   **Close** PrepareStatment 1 and ResultSet 1
  
      3. PrepareStatment 2 
         2.1   Object 2 Fetch Query
         2.1   Bind Object 2 from ResultSet 2
         2.1   Close PrepareStatment 2 and ResultSet 2
  
      4. PrepareStatment 3 
         2.1   Object 3 Fetch Query
         2.1   Bind Object 3 from ResultSet 3
         2.1   Close PrepareStatment 3 and ResultSet 3
  
      5. PrepareStatment 4 
         2.1   Object 4 Fetch Query
         2.1   Bind Object 4 from ResultSet 4
         2.1   Close PrepareStatment 4 and ResultSet 4
  
      6. PrepareStatment 5 
         2.1   Object 5 Fetch Query
         2.1   Bind Object 5 from ResultSet 5
         2.1   Close PrepareStatment 5 and ResultSet 5
  
      7. Close JDBC Connection in FINAL BLOCK
  
  }
  </code></pre>
  
  <p>And Another is </p>
  
  <pre><code> void fetchSeventObjectMethod(long id1,long id2,.....,long id5) {    
      call fetchObjectOneMethod(id1); 
      call fetchObjectTwoMethod(id2); 
      call fetchObjectTHreeMethod(id3); 
      call fetchObjectFourMethod(id4); 
      call fetchObjectFiveMethod(id5); 
      }
  
          void fetchObjectOneMethod(long id1) {    
              1. Open JDBC Connection      
              2. PrepareStatment 1 
                 2.1   Object 1 Fetch Query
                 2.1   Bind Object 1 from ResultSet 1
                 2.1   **Close** PrepareStatment 1 and ResultSet                          
              3. Close JDBC Connection in FINAL BLOCK           
          }
  
         void fetchObjectTwoMethod(long id2) {              
              1. Open JDBC Connection            
              2. PrepareStatment 1 
                 2.1   Object 1 Fetch Query
                 2.1   Bind Object 1 from ResultSet 1
                 2.1   **Close** PrepareStatment 1 and ResultSet 1                         
              3. Close JDBC Connection in FINAL BLOCK            
          }
  
         void fetchObjectTHreeMethod(long id3) {             
              1. Open JDBC Connection           
              2. PrepareStatment 1 
                 2.1   Object 1 Fetch Query
                 2.1   Bind Object 1 from ResultSet 1
                 2.1   **Close** PrepareStatment 1 and ResultSet 1                        
              3. Close JDBC Connection in FINAL BLOCK           
          }
  </code></pre>
  
  <p>Here scenario is void fetchSeventObjectMethod(....) is called by several threads at time upto thousands or more.</p>
  
  <p><strong>in case of first one Just Single Connection is Used
  in case of Second Five Connections are Used</strong></p>
  
  <p>Which is better option in performance consideration or is there is alternative way.
  Here I am using c3p0 connection pooling also.
  Please help me.</p>
  
  <p>Thank you</p>