pieces of code doesn't work with oracle
"kRAkEn/gORe" <[email protected]> Wed, 19 Dec 2007 10:22:56 +0100
| Newsgroups | gmane.comp.java.helma.general |
|---|---|
| Message-ID | <[email protected]> |
I'm using oracle 10gR2 with helma and "SELECT 1" isn't a valid sql
command in oracle (at least
"SELECT 1 FROM DUAL", so i get a "Connection closed" exception from
time to time while executing
queries...
public Connection getConnection(DbSource src) {
Connection con = (Connection) sqlConnections.get(src);
if (con != null && !testedConnections.contains(src)) {
// Check if the connection is still alive by executing a
simple statement.
try {
Statement stmt = con.createStatement();
stmt.execute("SELECT 1");
stmt.close();
testedConnections.add(src);
} catch (SQLException sx) {
try {
con.close();
} catch (SQLException ignore) {/* nothing to do */}
return null;
}
}
return con;
}
thanx