Injectable Interfaces
... SourceForge.net Logo
 
 
 
 
Latest
The latest version of Proxool is 0.9.1
Donations
You can donate to Proxool in the usual way:
sourceforge.net
 

When Proxool gives you a Statement or a Connection then it gives you a proxy object that delegates to the underlying (or delegate) driver. When it does so it automatically implements any interfaces that it finds. For instance, imagine your Xyz driver supplies you with a Statement XyzStatement that is actually an interface that extends the java.sql.Statement interface. When you ask Proxool for a Statement then you can cast it into an XyzStatement like this:

    Connection connection = DriverManager.getConnection(url);
    XyzStatement xyzStatement = (XyzStatement) connection.createStatement();
However, if XyzStatement is a class that implements java.sql.Statement then we are unable to extend it because of the Java limitation of only having one superclass. There is an alternative though: you have to write your own interface:
    package com.mycompany.jdbc;

    public interface XyzStatementIF {
        /**
         * Whatever methods in XyzStatement we want access to
         */
        void foo();
    }
Then, you inject that interface into the Proxool code by setting the appropriate configuration property:
    injectable-statement-interface = com.mycompany.jdbc.XyzStatementIF
You can do that for the following objects:
  • java.sql.Connection using injectable-connection-interface
  • java.sql.Statement using injectable-statement-interface
  • java.sql.PreparedStatement using injectable-prepared-statement-interface
  • java.sql.CallableStatement using injectable-callable-statement-interface