title: Error java:38: error: 'try' without 'catch', 'finally' or resource declarations
body: <p>I keep getting an error stating I need a <code>catch</code> clause to accompany the <code>try</code> (inside <code>public Connection getConnection()</code>). I dont understand why the compiler isn't noticing the <code>catch</code> directly under the <code>try</code>. Does anyone know why it won't compile? I checked all my brackets as well...</p>
  
  <pre><code>package crud.data;
  
  import java.sql.*;
  import javax.sql.DataSource;
  import javax.naming.InitialContext;
  import javax.naming.NamingException;
  
  public class ConnectionPool
  {
         private static ConnectionPool pool = null;
         private static DataSource dataSource = null;
  
  
         private ConnectionPool()
         {
             try
             {
                  InitialContext ic = new InitialContext();
                  dataSource = (DataSource)           
                          ic.lookup("java:/comp/env/jdbc/acm14n");
             }
             catch (NamingException e)
             {
                  System.out.println(e);
             }
       }
  
       public static synchronized ConnectionPool getInstance()
       {
              if(pool == null)
              {
                   pool = new ConnectionPool();
              } 
              return pool;
       }
  
       public Connection getConnection()
       {
           try
           {
               return dataSource.getConnection();
           }
           catch  (SQLException e)
           {
              System.out.println(e);
              return null;
           }  
       }
  
       public void freeConnection(Connection c)
       {
           try
           {
              c.close();
           } 
           catch (SQLException e)
           {
                  System.out.println(e);
           }
       }
  }
  </code></pre>