java : Using Static Method for obtaining Database Connection
<p>I am working on an existing Java EE based application. This features the following method for connecting to a database :</p>

<pre><code>public static java.sql.Connection connectionToDataBase(String jndiName,boolean flag)throws Exception 
{
DataSource ds =(javax.sql.DataSource) initCtx.lookup(jndiName);
return ds.getConnection();
    } catch (NamingException ne) {
            throw ne;
        } finally {
            try {
                if (initCtx != null)
                    initCtx.close();
            } catch (NamingException ne) {

                throw ne;
            }
        }
}
</code></pre>

<p>My question is whether using a static method for connecting to a database is correct?</p>
