Problem with OracleDataSource
Hi
I am using OracleDataSource in my StandAlone Application
Below are functions of class which configure datasource
private void configureDataSource()
{
try
{
// Load the properties file to get the connection information
// from the Connection.properties file
Properties prop = this.loadParams"com.abc.DBConnection");
ods.setServerName(prop.getProperty("HostName"));
ods.setDatabaseName( prop.getProperty("SID"));
ods.setPortNumber(new Integer( prop.getProperty("Port")).intValue());
ods.setDriverType("thin");
ods.setNetworkProtocol("tcp");
ods.setUser( prop.getProperty("UserName") );
ods.setPassword( prop.getProperty("Password"));
} catch (IOException ex) {
System.out.println("io exception in configure datasource is : " + ex.getMessage());
}
}//EO configure datasource
private Properties loadParams(String file) throws IOException
{
// Loads a ResourceBundle and creates Properties from it
Properties prop = new Properties();
ResourceBundle bundle = ResourceBundle.getBundle(file);
Enumeration enum = bundle.getKeys();
String key = null;
while (enum.hasMoreElements())
{
key = (String) enum.nextElement();
prop.put(key, bundle.getObject(key));
}
return prop;
}
But if the database goes down then the process is stucked because rest of the sequential statements will be executed even then. i want to find an automatic way of cleaning the closed connections and creating new connections when database is up. My finding is this that in app server below mentioned lines will solve the problem
<data-source
class="com.evermind.sql.DriverManagerDataSource"
name="OracleDS"
location="jdbc/OracleCoreDS"
pooled-location="jdbc/OracleCoreDS_non_tx"
xa-location="jdbc/xa/OracleXADS"
ejb-location="jdbc/OracleDSO"
connection-driver="oracle.jdbc.driver.OracleDriver"
username="scott"
password="tiger"
url="jdbc:oracle:thin:@localhost:1521:ORCL"
clean-available-connections-threshold="30"
rac-enabled="false"
inactivity-timeout="30"
/>
i want the same in my standalone application so do i have to write the suppporting code for it or there is an option available?

