
Classes | |
| class | ConnectionWrapper |
Public Member Functions | |
| void | freeConnection (Connection conn) |
| Connection | getConnection () |
| boolean | supportsTransaction () |
| String | toString () |
Static Public Member Functions | |
| static ERXJDBCConnectionBroker | connectionBrokerForAdaptor (EOAdaptor adaptor) |
| static ERXJDBCConnectionBroker | connectionBrokerForEntityNamed (String ename) |
| static ERXJDBCConnectionBroker | connectionBrokerForEoInEditingContext (EOEnterpriseObject eo) |
| static ERXJDBCConnectionBroker | connectionBrokerForModel (EOModel model) |
| static ERXJDBCConnectionBroker | connectionBrokerForModelWithName (String modelName) |
Static Public Attributes | |
| static final Logger | log = Logger.getLogger(ERXJDBCConnectionBroker.class) |
Package Attributes | |
| long | maxConnectionMillis |
Private Member Functions | |
| Connection | createConnection () throws SQLException |
| synchronized void | createWrapper () throws SQLException |
| void | destroy (int millis) throws SQLException |
| ERXJDBCConnectionBroker (NSDictionary dict) | |
| int | getOpenChannelCount () |
| void | setup (NSDictionary dict, int maxCheckoutSecond) |
| ConnectionWrapper | wrapperForConnection (Connection conn) |
Static Private Member Functions | |
| static synchronized ERXJDBCConnectionBroker | connectionBrokerForConnectionDictionary (NSDictionary d) |
| static ERXJDBCConnectionBroker | newConnectionBrokerWithConnectionDictionary (NSDictionary dict) |
Private Attributes | |
| boolean | active = true |
| int | activeConnections |
| String | dbDriver |
| String | dbLogin |
| String | dbPassword |
| String | dbServer |
| int | lastRoundRobinIndex |
| int | maxCheckoutMillis |
| int | maximumConnections |
| int | minimumConnections |
| Thread | pinger |
| Thread | reaper |
| boolean | supportsTransactions = false |
| ConnectionWrapper[] | wrappers |
Static Private Attributes | |
| static Hashtable | brokers = new Hashtable() |
| static final int | DEFAULTMAXCHECKOUTSECONDS = 600 |
dbSomePropertyGLOBAL, ModelName.DBSomeProperty or as someProperty in the connection dictionary.
java.sql.Connection con = ERXJDBCConnectionBroker.connectionBrokerForModel(myModel).getConnection();
try {
java.sql.Statement s = con.createStatement();
//now do something with the Statement
} finally {
ERXJDBCConnectionBroker.connectionBrokerForModel(myModel).freeConnection(con);
}
| ERXJDBCConnectionBroker | ( | NSDictionary | dict | ) | [private] |
| static ERXJDBCConnectionBroker connectionBrokerForAdaptor | ( | EOAdaptor | adaptor | ) | [static] |
| static synchronized ERXJDBCConnectionBroker connectionBrokerForConnectionDictionary | ( | NSDictionary | d | ) | [static, private] |
| static ERXJDBCConnectionBroker connectionBrokerForEntityNamed | ( | String | ename | ) | [static] |
| static ERXJDBCConnectionBroker connectionBrokerForEoInEditingContext | ( | EOEnterpriseObject | eo | ) | [static] |
| static ERXJDBCConnectionBroker connectionBrokerForModel | ( | EOModel | model | ) | [static] |
| static ERXJDBCConnectionBroker connectionBrokerForModelWithName | ( | String | modelName | ) | [static] |
| Connection createConnection | ( | ) | throws SQLException [private] |
| synchronized void createWrapper | ( | ) | throws SQLException [private] |
| void destroy | ( | int | millis | ) | throws SQLException [private] |
| void freeConnection | ( | Connection | conn | ) |
Frees a connection. Replaces connection back into the main pool for reuse.
Implements ERXJDBCAdaptor.ConnectionBroker.
| Connection getConnection | ( | ) |
This method hands out the connections in round-robin order. This prevents a faulty connection from locking up an application entirely. A browser 'refresh' will get the next connection while the faulty connection is cleaned up by the housekeeping thread.
If the min number of threads are ever exhausted, new threads are added up the the max thread count. Finally, if all threads are in use, this method waits 2 seconds and tries again, up to ten times. After that, it returns a null.
Implements ERXJDBCAdaptor.ConnectionBroker.
| int getOpenChannelCount | ( | ) | [private] |
| static ERXJDBCConnectionBroker newConnectionBrokerWithConnectionDictionary | ( | NSDictionary | dict | ) | [static, private] |
| void setup | ( | NSDictionary | dict, | |
| int | maxCheckoutSecond | |||
| ) | [private] |
Housekeeping thread. Runs in the background with low CPU overhead. Connections are checked for warnings and closure and are periodically restarted. This thread is a catchall for corrupted connections and prevents the buildup of open cursors. (Open cursors result when the application fails to close a Statement). This method acts as fault tolerance for bad connection/statement programming.
Less safe shutdown. Uses default timeout value. This method simply calls the destroy() method with a millis value of 10000 (10 seconds) and ignores SQLException thrown by that method.
| boolean supportsTransaction | ( | ) |
| String toString | ( | ) |
| ConnectionWrapper wrapperForConnection | ( | Connection | conn | ) | [private] |
Returns the local JDBC ID for a connection.
boolean active = true [private] |
int activeConnections [private] |
Hashtable brokers = new Hashtable() [static, private] |
String dbPassword [private] |
final int DEFAULTMAXCHECKOUTSECONDS = 600 [static, private] |
int lastRoundRobinIndex [private] |
final Logger log = Logger.getLogger(ERXJDBCConnectionBroker.class) [static] |
int maxCheckoutMillis [private] |
long maxConnectionMillis [package] |
int maximumConnections [private] |
int minimumConnections [private] |
Thread pinger [private] |
Thread reaper [private] |
boolean supportsTransactions = false [private] |
ConnectionWrapper [] wrappers [private] |
1.5.8