01: package org.mmbase.storage.implementation.database;
02:
03: import java.lang.reflect.Method;
04: import java.sql.*;
05: import org.mmbase.module.database.JDBC;
06: import org.mmbase.module.Module;
07:
08: import org.mmbase.util.logging.Logger;
09: import org.mmbase.util.logging.Logging;
10: import org.mmbase.module.database.MultiConnection;
11:
12: public class InformixStorageManager extends DatabaseStorageManager {
13: private static final Logger log = Logging
14: .getLoggerInstance(InformixStorageManager.class);
15:
16: /**
17: * Safely closes the active connection.
18: * If a transaction has been started, the connection is not closed.
19: */
20: protected void releaseActiveConnection() {
21: if (!(inTransaction && factory.supportsTransactions())
22: && activeConnection != null) {
23: try {
24: // ensure that future attempts to obtain a connection (i.e.e if it came from a pool)
25: // start with autocommit set to true
26: // needed because Query interface does not use storage layer to obtain transactions
27: activeConnection.setAutoCommit(true);
28: closeInformix();
29: activeConnection.close();
30: } catch (SQLException se) {
31: // if something went wrong, log, but do not throw exceptions
32: log.error("Failure when closing connection: "
33: + se.getMessage());
34: }
35: activeConnection = null;
36: }
37: }
38:
39: private void closeInformix() {
40: Connection con = ((MultiConnection) activeConnection)
41: .unwrap(Connection.class);
42: try {
43: Method scrub = Class.forName(
44: "com.informix.jdbc.IfxConnection").getMethod(
45: "scrubConnection");
46: scrub.invoke(con);
47: ((JDBC) Module.getModule("jdbc")).getSupport()
48: .initConnection(con);
49: } catch (Exception e) {
50: log.error("Exception while calling releaseBlob(): "
51: + e.getMessage());
52: }
53: }
54: }
|