@Override public AccessControlModel load(String id, boolean cacheAllowed) { ConnectionPool pool = DbcpSource.getPool(dbcpId); if (pool == null){ LOG.error("Can not find the connection pool named:" + dbcpId); return null; } Connection conn = null; boolean error = false; try { conn = pool.getConnection(); if (conn != null){ return loadACM(conn,id); }else{ LOG.error("Can not get db connection from pool:" + dbcpId); return null; } }catch (BaseException ex){ LOG.error(ExceptionUtils.getStackTrace(ex)); return null; }finally{ pool.recycle(conn, error); } }
@Override public AccessAppKey load(String id, boolean cacheAllowed) { ConnectionPool pool = DbcpSource.getPool(dbcpId); if (pool == null){ LOG.error("Can not find the connection pool named:" + dbcpId); return null; } Connection conn = null; boolean error = false; try { conn = pool.getConnection(); if (conn != null){ return loadAAK(conn,id); }else{ LOG.error("Can not get db connection from pool:" + dbcpId); return null; } }catch (BaseException ex){ LOG.error(ExceptionUtils.getStackTrace(ex)); return null; }finally{ pool.recycle(conn, error); } }
@Override protected void onExecute(XsObject root,XsObject current, LogicletContext ctx, ExecuteWatcher watcher) { ConnectionPool pool = DbcpSource.getPool(dbcpId); if (pool == null) { logger.error("Can't get connection pool by dbcpId:" + dbcpId + ", The database connection pool is null!"); return ; } Connection conn = pool.getConnection(); if (conn == null) { logger.error("The database connection is null!"); return ; } boolean hasError = false; try { conn.setAutoCommit(autoCommit); ctx.setObject(dbconn, conn); super.onExecute(root, current, ctx, watcher); } catch (SQLException ex) { hasError = true; throw new BaseException("core.e1300",ex.getMessage()); } finally { ctx.removeObject(dbconn); pool.recycle(conn, hasError); } }
found = pool.getConnection(timeout);
boolean error = false; try { conn = pool.getConnection(); if (conn != null){ long pid = DBTools.selectAsLong(conn, "select pid from util_snowflake where client = ?", -1, client);
boolean error = false; try { conn = pool.getConnection(); if (conn != null){ List<Map<String,Object>> result = DBTools.listAsObject(conn,sql,lastScanTime);
return ; conn = pool.getConnection(); if (conn == null) { logger.error("The database connection is null!");
public CacheObject loadObject(String id,Object[] ids) { ConnectionPool pool = DbcpSource.getPool(dbcp); if (pool == null) { throw new BaseException("core.e1003", "Can not get a connection pool named " + dbcp); } Connection conn = pool.getConnection(); try { List<String> result = new ArrayList<String>(); DBTools.list(conn, result,single,sql,ids); if (!result.isEmpty()){ CacheObject found = new CacheObject.Simple(id); for (String item:result){ found.sAdd(CacheObject.DEFAULT_GROUP, item); } if (found.isValid()){ return found; } } return null; } finally { pool.recycle(conn); } } }
protected CacheObject loadObject(String id,Object[] ids) { ConnectionPool pool = DbcpSource.getPool(dbcp); if (pool == null) { throw new BaseException("core.e1003", "Can not get a connection pool named " + dbcp); } Connection conn = pool.getConnection(); try { Map<String,Object> result = DBTools.selectAsObjects(conn,sql, ids); if (result != null){ CacheObject found = new CacheObject.Simple(id); found.fromJson(result); return found; } return null; } finally { pool.recycle(conn); } } }
boolean error = false; try { conn = pool.getConnection(); if (conn != null){ DBTools.setAutoCommit(conn, false);