Examples of PooledConnection


Examples of anvil.database.PooledConnection

 
 
  public Tribe createTribe(String name) throws OperationFailedException {
    if (name == null) throw new OperationFailedException("Null tribe name!");
   
    PooledConnection connImpl = null;
    DirContext ctx = null;
 
    try {
      connImpl = _manager.acquire(_contextPool);
      ctx = (DirContext)connImpl.getConnection();
     
      Attributes at = new BasicAttributes();
      at.put(groupObjectClass);
     
      at.put("cn", name);
View Full Code Here

Examples of anvil.database.PooledConnection

  {
    if (username == null) throw new OperationFailedException("Null username!");
    username = username.trim().toLowerCase();
    if (!checkEmail(username)) throw new OperationFailedException("Username isn't a valid email address!");
   
    PooledConnection connImpl = null;
    DirContext ctx = null;
 
    try {
      connImpl = _manager.acquire(_contextPool);
      ctx = (DirContext)connImpl.getConnection();
     
      Attributes at = new BasicAttributes();
      at.put("facsimileTelephoneNumber", password);
      at.put(objectClassAttr);
     
View Full Code Here

Examples of anvil.database.PooledConnection

    return new Perl5Matcher().matches(email, EMAIL_PATTERN);
  }


  PermissionCollection loadPermissions(String dn) {
    PooledConnection connImpl = null;
    DirContext ctx = null;
 
    try {
      connImpl = getConnection();
      ctx = (DirContext)connImpl.getConnection();
      return loadPermissions(ctx, dn);
 
    } catch (Exception e) {
      _zone.log().error("LDAPRealm.loadPermissions(): "+e);
     
View Full Code Here

Examples of anvil.database.PooledConnection

    return result;
  }
 
 
  PermissionCollection addPermission(Permission perm, String dn) throws OperationFailedException {
    PooledConnection connImpl = null;
    DirContext ctx = null;
 
    try {
      connImpl = getConnection();
      ctx = (DirContext)connImpl.getConnection();

      PermissionCollection storage = LDAPRealm.loadPermissions(ctx, dn);
      boolean found = false;
      for (Enumeration enu=storage.elements(); enu.hasMoreElements(); ) {
        if (perm.equals(enu.nextElement())) {
View Full Code Here

Examples of anvil.database.PooledConnection

    }
  }


  PermissionCollection removePermission(Permission perm, String dn) throws OperationFailedException {
    PooledConnection connImpl = null;
    DirContext ctx = null;
 
    try {
      connImpl = getConnection();
      ctx = (DirContext)connImpl.getConnection();

      PermissionCollection storage = LDAPRealm.loadPermissions(ctx, dn);
      PermissionCollection altered = new Permissions();
     
      boolean found = false;
View Full Code Here

Examples of anvil.database.PooledConnection

  }
 
 
  /*package*/ Object perform(Action action) throws OperationFailedException
  {
    PooledConnection impl = null;
    try {
      impl = _manager.acquire(_poolname);
    } catch (NoConnectionPoolException e) {
      String msg = "Couldn't acquire connection: " + e;
      _zone.log().error(e);
      throw new OperationFailedException(msg);
     
    } catch (CannotReturnPooledConnectionException e) {
      String msg = "Couldn't acquire connection: " + e;
      _zone.log().error(e);
      throw new OperationFailedException(msg);
    }
   
    Connection conn = (Connection)impl.getConnection();
   
    try {
      /* conn.setAutoCommit(false) */
      Object rv = action.perform(conn);
      /* conn.commit(); */
      return rv;
   
    } catch (SQLException e) {
      try {
        /* conn.rollback(); */
        conn.close();
      } catch (Throwable t) {
      }
      _zone.log().error("SQL operation failed", e);
      throw new OperationFailedException(e.toString());
     
    } catch (OperationFailedException e) {
      try {
        /* conn.rollback(); */
        conn.close();
      } catch (Throwable t) {
      }
      _zone.log().error("Operation failed", e);
      e.fillInStackTrace();
      throw e;
     
    } finally {
      impl.release();
    }
   
  }
View Full Code Here

Examples of anvil.database.PooledConnection

    if (i>0) {
      catalog = ckey.substring(i+1);
      ckey = ckey.substring(0, i);
    }
   
    PooledConnection connImpl = null;
    Connection conn = null;
   
    try {

      ConnectionManager manager = context.address().getZone().getManagerFor(ckey);
      connImpl = manager.acquire(ckey);
      conn = (Connection)connImpl.getConnection();
      if (catalog != null) {
        conn.setCatalog(catalog);
      }
      conn.setAutoCommit(autoCommit);
      conn.setReadOnly(readOnly);
      return connImpl;
     
    } catch (CannotReturnPooledConnectionException e) {
      throw context.AcquireError(e.getMessage());
    } catch (NoConnectionPoolException e) {
      throw context.AcquireError("No such pool: " + ckey);
    } catch (SQLException e) {
      if (conn != null) {
        try {
          conn.close();
        } catch (Exception e2) {
        }
      }
      connImpl.release();
      throw context.exception(e);
    }
  }
View Full Code Here

Examples of anvil.database.PooledConnection

  /// @throws AcquireError If connection could not be retrieved
  /// @throws SQLError If SQL error occured

  public static final Any query(Context context, String ckey, String query, Any[] parameters)
  {
    PooledConnection connImpl = acquireConnection(context, ckey, true, false);
    if (connImpl == null) {
      return Any.NULL;
    }
    Connection conn = (Connection)connImpl.getConnection();
    try {
      Statement stmt = conn.createStatement();
      stmt.setEscapeProcessing(false);
      String queryString;
      if (parameters.length == 0) {
        queryString = query;
      } else {
        queryString = SQLUtil.buildQueryString(query, parameters, 0);
      }
      Any returnValue;
      if (stmt.execute(queryString)) {
        returnValue = new AnyResultSet(stmt.getResultSet(), stmt);
      } else {
        returnValue = Any.create(stmt.getUpdateCount());
        stmt.close();
      }
      return returnValue;
    } catch (SQLException e) {
      try {
        conn.close();
      } catch (Exception e2) {
      }
      throw context.exception(e);
    } finally {
      connImpl.release();
    }
  }
View Full Code Here

Examples of anvil.database.PooledConnection

  /// @throws AcquireError If connection could not be retrieved
  /// @throws SQLError If SQL error occured
  public static final Object[] p_acquire = { null, "key", "*autoCommit", Boolean.TRUE, "*readOnly", Boolean.FALSE };
  public static final Any acquire(Context context, String ckey, boolean autoCommit, boolean readOnly)
  {
    PooledConnection connImpl = acquireConnection(context, ckey, autoCommit, readOnly);
    if (connImpl == null) {
      return Any.NULL;
    } else {
      return new AnyConnection(connImpl);
    }
View Full Code Here

Examples of anvil.database.PooledConnection

    this.fullDN = realm.createGroupDN(name);
    this.isRoot = isRoot;
    log = realm.getLog();
   
    if (!isRoot) {
      PooledConnection connImpl = null;
      DirContext ctx = null;
      boolean tribeFound = false;
   
      try {
        connImpl = realm.getConnection();
        ctx = (DirContext)connImpl.getConnection();
   
        ctx.getAttributes(dn, new String[] { "cn" });
        tribeFound = true;
      } catch (NameNotFoundException nnfe) {
        //not found
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.