oracle database connection in Java EE
<p>I am new to java, I have a doubt:</p>

<p>I am retunging con from this method:</p>

<pre><code>package mypackage;
public class DBconnection {
 Connection con = null;

public Connection getConnection() throws Exception, SQLException
{
    try
    {
         Class.forName("oracle.jdbc.driver.OracleDriver");
         con=DriverManager.getConnection("jdbc:oracle:thin:@zzz:1521:zzz","zzz", "zzz");
    }
    catch(Exception e)
    {

    }
    return con;
}

public void removeConnection() throws SQLException
{
    con.close();
}
</code></pre>

<p>} </p>

<p>Now when I am calling that <code>getConnection();</code> method then I am getting con , now while using prepareStatement how can I use that in my query??</p>

<p>I called it </p>

<pre><code>DBconnection dbconnect = new DBconnection();

 dbconnect.getConnection().prepareStatement(""); //is this the right way to write??
</code></pre>

<p>or </p>

<pre><code>DBconnection dbconnect = new DBconnection();
dbconnect.getConnection();

dbconnect.con.prepareStatement(""); //is this the right way to write??
</code></pre>

<p>after these how should i close the connection??</p>

<pre><code>dbconnect.removeConnection();
</code></pre>
