Im trying to display some data from Oracle DB. Its taking more than 4 sec to obtain the connection.To read the entire data it needs only 1-2 seconds.So how can i improve overall response time.
I tried in this way
public class ConnectionManager {
public static Connection getConnection() {
Connection conn = null;
try {
OracleDataSource ods = new OracleDataSource();
java.util.Properties prop = new java.util.Properties();
prop.setProperty("MinLimit", "2");
prop.setProperty("MaxLimit", "10");
ods.setURL(DBProps.getProperty("oracle.url"));
ods.setConnectionCachingEnabled(true);
ods.setConnectionCacheProperties (prop);
ods.setConnectionCacheName("Cache");
conn = ods.getConnection(DBProps.getProperty("oracle.user"), DBProps.getProperty("oracle.password"));
} catch (Exception e) {
e.printStackTrace();
}
return conn;
}
}
And tried in traditional way as well
public static Connection getConnection() {
Connection conn = null;
try {
Class.forName("oracle.jdbc.driver.OracleDriver");
conn = DriverManager.getConnection(DBProps.getProperty("oracle.url"), DBProps.getProperty("oracle.user"), DBProps.getProperty("oracle.password"));
} catch (SQLException | ClassNotFoundException e) {
e.printStackTrace();
}
return conn;
}