beehive-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Drew Varner <>
Subject Idea for JDBC system control
Date Fri, 01 Dec 2006 02:40:32 GMT
I was playing around with an idea for the JDBC system control. The  
ability to pass it a Connection object other than one declared in  
it's annotations.

Here are a couple of use cases:

1) Integration with other persistence mechanisms. Let's say I have a  
DAO that I can pass a Connection to. I can place the DAO and and JDBC  
Control operations in the same transaction.

Connection conn = JDBCUtils.getConnection();

2) Use it to put multiple JDBC Controls in the same db transaction  
(same as above, replace the DAO with another JDBC control)

3) Make unit testing easier. You can pass a connection to a test  
database into the control during testing and don't have to mess with  
the JNDI setup for out-of-container testing.

4) Support for non-standard Connection sources. If you are using a  
JDBC Control in a Struts app, you can grab the DataSource via the  
Struts DataSource mechanism.

Setting an external connection would be manipulated by methods, not  

public void setExternalConnection(Connection conn);
public Connection getExternalConnection();

The control implementation would never close the external connection.

Would it be worth adding?

- Drew

View raw message