arthurblake / log4jdbc

log4jdbc is a Java JDBC driver that can log SQL and/or JDBC calls (and optionally SQL timing information) for other JDBC drivers using the Simple Logging Facade For Java (SLF4J) logging system.
506 stars 148 forks source link

make RdbmsSpecifics public #74

Closed jadetang closed 8 years ago

jadetang commented 8 years ago

I try to use log4jdbc with spring, but I don't want to change my url style. So I use AOP, here is my Interceptor

public class DataSourceSpyInterceptor implements MethodInterceptor {

    private RdbmsSpecifics rdbmsSpecifics = null;

    private RdbmsSpecifics getRdbmsSpecifics(Connection conn) {
        if(rdbmsSpecifics == null) {
            rdbmsSpecifics = DriverSpy.getRdbmsSpecifics(conn);
        }
        return rdbmsSpecifics;
    }

    public Object invoke(MethodInvocation invocation) throws Throwable {
        Object result = invocation.proceed();
        if(SpyLogFactory.getSpyLogDelegator().isJdbcLoggingEnabled()) {
            if(result instanceof Connection) {
                Connection conn = (Connection)result;
                return new ConnectionSpy(conn,DriverSpy.getRdbmsSpecifics(conn));
            }
        }
        return result;
    }
}

and this is how I config in Spring

<bean id="log4jdbcInterceptor" class="net.sf.log4jdbc.DataSourceSpyInterceptor" />

    <bean id="dataSourceLog4jdbcAutoProxyCreator" class="org.springframework.aop.framework.autoproxy.BeanNameAutoProxyCreator">
        <property name="interceptorNames">
            <list>
                <value>log4jdbcInterceptor</value>
            </list>
        </property>
        <property name="beanNames">
            <list>
                <value>verticaDS</value>
                <value>mysqlDS</value>
            </list>
        </property>
    </bean>

But my Interceptor should be in the net.sf.log4jdbc package since the class RdbmsSpecifics is not public, so I think it is better to make it public.

arthurblake commented 8 years ago

Thanks.

jadetang commented 8 years ago

would you release another version of this project to maven repository? So I can sync to my company private repository.

arthurblake commented 8 years ago

I don't use Maven. You can use the provided ant build script, or you can update Maven if you know how.

jadetang commented 8 years ago

http://mvnrepository.com/artifact/com.googlecode.log4jdbc/log4jdbc/1.2#mvn
this is the site of your project on a public maven repository, I thought it was you deployed the jar.