ConnectionWrapper(Connection con) {
   this.connection =
       (Connection)
           Proxy.newProxyInstance(
               con.getClass().getClassLoader(), con.getClass().getInterfaces(), this);
   m_originConnection = con;
 }
Exemple #2
0
 public static final Connection getConnection() throws SQLException {
   Connection conn = conns.get();
   if (conn == null || conn.isClosed()) {
     conn = _getConnection();
     if (conn == null) throw new SQLException("Unabled to get connection.");
     conns.set(conn);
     // RequestContext ctx = RequestContext.get();
     // connectionContext.put(
     // Thread.currentThread().getId(),
     // new ConnectionContext(new Exception(), (ctx != null) ? ctx
     // .ip() : null, (ctx != null) ? ctx.uri() : null,
     // (ctx != null) ? ctx.request().getParameterMap()
     // : null));
   }
   return (show_sql && !Proxy.isProxyClass(conn.getClass()))
       ? new _DebugConnection(conn).getConnection()
       : conn;
 }
  /** ** XAConnection interface *** */
  public Connection getConnection() throws SQLException {
    if (logger.logDebug()) debug("PGXAConnection.getConnection called");

    Connection conn = super.getConnection();

    // When we're outside an XA transaction, autocommit
    // is supposed to be true, per usual JDBC convention.
    // When an XA transaction is in progress, it should be
    // false.
    if (state == STATE_IDLE) conn.setAutoCommit(true);

    /*
     * Wrap the connection in a proxy to forbid application from
     * fiddling with transaction state directly during an XA transaction
     */
    ConnectionHandler handler = new ConnectionHandler(conn);
    return (Connection)
        Proxy.newProxyInstance(
            getClass().getClassLoader(),
            new Class[] {Connection.class, PGConnection.class},
            handler);
  }
Exemple #4
0
 /**
  * Returns the conn.
  *
  * @return Connection
  */
 public Connection getConnection() {
   return (Connection)
       Proxy.newProxyInstance(
           conn.getClass().getClassLoader(), conn.getClass().getInterfaces(), this);
 }
 /** @deprecated use or rewrite in terms of ReflectUtils.findProxyConstructor() */
 private static Constructor createProxyConstructor(Class intfc) throws NoSuchMethodException {
   Class[] proxyInterfaces = new Class[] {intfc};
   Class proxyCl =
       Proxy.getProxyClass(C3P0PooledConnection.class.getClassLoader(), proxyInterfaces);
   return proxyCl.getConstructor(PROXY_CTOR_ARGS);
 }