package org.ovirt.engine.core.dal.dbbroker;

import java.io.PrintWriter;
import java.sql.Connection;
import java.sql.SQLException;

import javax.sql.DataSource;

public class PGHack implements DataSource {

    DataSource real;

    public PGHack(DataSource d) {
        this.real = d;
    }

    @Override
    public Connection getConnection() throws SQLException {
        Connection conn = real.getConnection();
        conn.setAutoCommit(false);
        return conn;
    }

    @Override
    public Connection getConnection(String username, String password) throws SQLException {
        Connection conn = real.getConnection(username, password);
        conn.setAutoCommit(false);
        return conn;
    }

    @Override
    public PrintWriter getLogWriter() throws SQLException {
        return real.getLogWriter();
    }

    @Override
    public int getLoginTimeout() throws SQLException {
        return real.getLoginTimeout();
    }

    @Override
    public void setLogWriter(PrintWriter out) throws SQLException {
        real.setLogWriter(out);

    }

    @Override
    public void setLoginTimeout(int seconds) throws SQLException {
        real.setLoginTimeout(seconds);

    }

    @Override
    public boolean isWrapperFor(Class<?> iface) throws SQLException {
        return real.isWrapperFor(iface);
    }

    @Override
    public <T> T unwrap(Class<T> iface) throws SQLException {
        return real.unwrap(iface);
    }

}

@@ -123,16 +123,98 @@
 ception;
+%0Aimport java.sql.SQLFeatureNotSupportedException;%0Aimport java.util.logging.Logger;
 %0A%0Aimport
@@ -1520,10 +1520,214 @@
 %0A    %7D%0A%0A
+    // In Java 7 the override annotation should be uncommented.%0A    // @Override%0A    public Logger getParentLogger() throws SQLFeatureNotSupportedException %7B%0A        return real.getParentLogger();%0A    %7D%0A%0A
 %7D%0A

Add methods missing from PGHack