KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > mmbase > storage > implementation > database > InformixStorageManager


1 package org.mmbase.storage.implementation.database;
2
3 import java.lang.reflect.Method JavaDoc;
4 import java.sql.*;
5 import java.util.List JavaDoc;
6
7 import org.mmbase.module.core.MMObjectNode;
8 import org.mmbase.core.CoreField;
9 import org.mmbase.util.logging.Logger;
10 import org.mmbase.util.logging.Logging;
11 import org.mmbase.module.database.MultiConnection;
12
13 public class InformixStorageManager extends DatabaseStorageManager {
14     private static final Logger log = Logging.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()) && activeConnection != null) {
22             try {
23                 // ensure that future attempts to obtain a connection (i.e.e if it came from a pool)
24
// start with autocommit set to true
25
// needed because Query interface does not use storage layer to obtain transactions
26
activeConnection.setAutoCommit(true);
27                 closeInformix();
28                 activeConnection.close();
29             } catch (SQLException se) {
30                 // if something went wrong, log, but do not throw exceptions
31
log.error("Failure when closing connection: " + se.getMessage());
32             }
33             activeConnection = null;
34         }
35     }
36
37     private void closeInformix() {
38         Connection con = ((MultiConnection)activeConnection).getRealConnection();
39         try {
40             Method JavaDoc scrub = Class.forName("com.informix.jdbc.IfxConnection").getMethod("scrubConnection", null);
41             scrub.invoke(con, null);
42         } catch (Exception JavaDoc e) {
43             log.error("Exception while calling releaseBlob(): " + e.getMessage());
44         }
45     }
46 }
47
Popular Tags