best way to use context.xml

I have made a web application using tomcat that is connecting to the database and made some transactions on it, but my database oracle admin is complaining of so many connection from it and tells me that it is always cause the database to hang up due to many connection . so my question is what the best context.xml file to use and what modification should i do to mine?

my context.xml

<?xml version="1.0" encoding="UTF-8"?>
<Context path="/applicationName">
    <Resource driverClassName="oracle.jdbc.OracleDriver"
        maxActive="100" maxIdle="-1" maxWait="30000" name="name" password="password"
        type="javax.sql.DataSource" url="url"
        username="username" />
    </Context>

my Dao Class

  public Dao(){
}

Context initContext;
Context envContext;
DataSource ds;
Connection conn;
public Connection getConnection() throws Exception {
    initContext = new InitialContext();
    envContext = (Context) initContext.lookup("java:/comp/env");
    ds = (DataSource) envContext.lookup("name");
    conn = ds.getConnection();
    if(conn != null){
        return conn;
    }
    return null;
}


Source: oracle

Leave a Reply