H
HalcyonWild
Hello all,
I am using a weblogic server. I am trying to get a connection from a
DataSource using following code.
I am not sure if I should do anything with the DataSource as part of
cleanup. There is no close method for DataSource, nor any other method
whose name suggests that it should be used for cleanup.
I am closing my connections, but what should I do with DataSource. Code
listing below.
Thanks.
====================
private DataSource src = null;
private final String DATA_SRC = "NonXADataSource";
private Connection getConnection() {
Connection c = null;
try {
if (src == null) {
src = DataSourceFactory.getDataSource(DATA_SRC);
}
c = src.getConnection();
return c;
} catch (SQLException ex) {
closeConnection(c);
throw new RuntimeException(
"Couldn't get connection for " + DATA_SRC, ex);
}
}
private static void closeConnection(Connection c) {
try {
if (c != null && !c.isClosed()) {
c.close();
}
} catch (SQLException se) {
logger.log("\n\n****************\n\nException while closing
connection", se);
}
}
=================
I am using a weblogic server. I am trying to get a connection from a
DataSource using following code.
I am not sure if I should do anything with the DataSource as part of
cleanup. There is no close method for DataSource, nor any other method
whose name suggests that it should be used for cleanup.
I am closing my connections, but what should I do with DataSource. Code
listing below.
Thanks.
====================
private DataSource src = null;
private final String DATA_SRC = "NonXADataSource";
private Connection getConnection() {
Connection c = null;
try {
if (src == null) {
src = DataSourceFactory.getDataSource(DATA_SRC);
}
c = src.getConnection();
return c;
} catch (SQLException ex) {
closeConnection(c);
throw new RuntimeException(
"Couldn't get connection for " + DATA_SRC, ex);
}
}
private static void closeConnection(Connection c) {
try {
if (c != null && !c.isClosed()) {
c.close();
}
} catch (SQLException se) {
logger.log("\n\n****************\n\nException while closing
connection", se);
}
}
=================