Currently the network server relies on some embedded implementation specific methods on embedded JDBC objects such as EmbedConnection etc. A few of these methods are implementation specific, and a few are standard but only available in jdk 1.4 interfaces where the server needs to run on jdk 1.3. The current approach is ad-hoc, using either reflection or explicitly casting the object from its standard interface to the embedded implementation. With XA this has led to bugs and the requirement to expose the underlying Statement object for a BrokeredStatement, this is bad because it then allows applications to by-pass the wrapping function performed by the brokering objects and obtain the underlying objects. From there an application could possibly hold onto a connection after it has been returned to a pool.
I propose to formalize the interface between the network server and engine's embedded JDBC objects through a set of interfaces. These interfaces would be implemented by the brokered and embedded objects. Then network server would interact with the engine's JDBC objects through these interfaces, thus not needing reflection or special casing for XA connections. An initial example of one of these interfaces is in-line below. Their use could be expanded in the future to support JDBC 3.0/4.0 mismatches and internal optimizations, such as fetching data from a ResultSet in a optimal way for the network server. I imagine that initially there will be three such interfaces EngineConnection, EnginePreparedStatement and EngineResultSet. Comments? Dan. package org.apache.derby.iapi.jdbc; /** * Additional methods the Engine exposes on its Connection object * implementations. An internal api only, mainly for the network * server. Allows consistent interaction between EmbedConnections * and BrokeredConnections. * */ public interface EngineConnection extends Connection { /** * Prepare a statement with holdability. * Identical to JDBC 3.0 method, to allow holdabilty * to be supported in JDK 1.3 by the network server, * e.g. when the client is jdk 1.4 or above. * Can be removed once JDK 1.3 is no longer supported. */ public PreparedStatement prepareStatement(String sql, int resultSetType, int resultSetConcurrency, int resultSetHoldability) throws SQLException; /** * Get the holdability of the connection. * Identical to JDBC 3.0 method, to allow holdabilty * to be supported in JDK 1.3 by the network server, * e.g. when the client is jdk 1.4 or above. * Can be removed once JDK 1.3 is no longer supported. */ public int getHoldability(); }