Exemple #1
0
 /**
  * Returns a connection and removes it from list with opened connections if requested.
  *
  * @param ctx query context
  * @param del flag indicating if connection has to be removed
  * @return connection
  * @throws QueryException query exception
  */
 private Connection connection(final QueryContext ctx, final boolean del) throws QueryException {
   final int id = (int) checkItr(expr[0].item(ctx, input));
   final Object obj = ctx.jdbc.get(id);
   if (obj == null || !(obj instanceof Connection)) NOCONN.thrw(input, id);
   if (del) ctx.jdbc.remove(id);
   return (Connection) obj;
 }
Exemple #2
0
 /**
  * Executes a query, update or prepared statement.
  *
  * @param ctx query context
  * @return result
  * @throws QueryException query exception
  */
 private Iter execute(final QueryContext ctx) throws QueryException {
   final int id = (int) checkItr(expr[0].item(ctx, input));
   final Object obj = ctx.jdbc.get(id);
   if (obj == null) throw NOCONN.thrw(input, id);
   // Execute query or prepared statement
   return obj instanceof Connection
       ? executeQuery((Connection) obj, ctx)
       : executePrepStmt((PreparedStatement) obj, ctx);
 }