Returns a opened connection resource. If a previous close connection
resource already exists, this already existing connection resource is
returned.

@return opened connection resource
@throws EFapsException if connection resource cannot be created
518544
public ConnectionResource getConnectionResource()
        throws EFapsException
    {
        try {
            if (this.connectionResource == null) {
                this.connectionResource = new ConnectionResource(Context.DATASOURCE.getConnection());
            }
        } catch (final SQLException e) {
            throw new EFapsException(getClass(), "getConnectionResource.SQLException", e);
        }
        return this.connectionResource;
    }
81061
public Set<AccessSet> getAccessSets()
        throws EFapsException
    {
        if (!this.checked4AccessSet) {
            this.checked4AccessSet = true;
            final QueryBuilder queryBldr = new QueryBuilder(CIAdminAccess.AccessSet2DataModelType);
            queryBldr.addWhereAttrEqValue(CIAdminAccess.AccessSet2DataModelType.DataModelTypeLink, getId());
            final MultiPrintQuery multi = queryBldr.getPrint();
            multi.addAttribute(CIAdminAccess.AccessSet2DataModelType.AccessSetLink);
            multi.executeWithoutAccessCheck();
            while (multi.next()) {
                final Long accessSet = multi.<Long>getAttribute(CIAdminAccess.AccessSet2DataModelType.AccessSetLink);
                AccessSet.get(accessSet);
                this.accessSets.add(accessSet);
            }
            setDirty();
        }
        final Set<AccessSet> ret = new HashSet<>();
        for (final Long id : this.accessSets) {
            ret.add(AccessSet.get(id));
        }
        return Collections.unmodifiableSet(ret);
    }
39691
private Connection getPooledConnection() throws SQLException {
    PooledConnection pc = null;
    synchronized (lock) {
      if (available == null) {
        throw new PSQLException(GT.tr("DataSource has been closed."),
            PSQLState.CONNECTION_DOES_NOT_EXIST);
      }
      while (true) {
        if (!available.isEmpty()) {
          pc = available.pop();
          used.push(pc);
          break;
        }
        if (maxConnections == 0 || used.size() < maxConnections) {
          pc = source.getPooledConnection();
          used.push(pc);
          break;
        } else {
          try {
            // Wake up every second at a minimum
            lock.wait(1000L);
          } catch (InterruptedException e) {
          }
        }
      }
    }
    pc.addConnectionEventListener(connectionEventListener);
    return pc.getConnection();
  }
322083
public Connection getConnection() throws SQLException {
		Connection conn = threadLocal.get();
		if (conn != null)
			return conn;
		return showSql ? new SqlReporter(dataSource.getConnection()).getConnection() : dataSource.getConnection();
	}
702634
@Override
   public Connection getConnection() throws SQLException
   {
      Connection conn = null;
      if (this.hds != null) {
         conn = this.hds.getConnection();
      }

      return conn;
   }
984468
public Object getObject()
        throws EFapsException
    {
        Object ret = null;
        if (this.valueSelect == null) {
            // if the fromSelect has data
            if (this.fromSelect.hasResult()) {
                // and there are more than one id the current object must not be null
                if (this.idList.size() > 1 && this.currentObject != null) {
                    ret = this.fromSelect.getMainOneSelect().getObject(this.currentObject);
                // or if there is only one id the first objectvalue must not be null
                } else if (this.idList.size() == 1 && this.objectList.get(0) != null) {
                    ret = this.fromSelect.getMainOneSelect().getObject(this.currentObject);
                }
            }
        } else {
            // if the currentObject is not null it means that the values are
            // retrieved by iteration through the object list
            if (this.currentId != null) {
                ret = this.valueSelect.getValue(this.currentObject);
            } else {
                ret = this.valueSelect.getValue(this.objectList);
            }
        }
        return ret;
    }
430257
public Connection getConnection() throws SQLException {
		
		FinalWrapper<BoneCP> wrapper = this.pool;

        if (wrapper == null) {
                synchronized (this) {
                        if (this.pool == null) {
                        	try{
                        		if (this.getDriverClass() != null){
                        			loadClass(this.getDriverClass());
                        		}
    					
                        		logger.debug(this.toString());
                        		this.pool = new FinalWrapper<BoneCP>(new BoneCP(this));
    				    
                        	} catch (ClassNotFoundException e) {
                        		throw new SQLException(PoolUtil.stringifyException(e));
                        	}
                        }

                        wrapper = this.pool;
                } 
        }

        return wrapper.value.getConnection();
     }
541257
@Path("connection")
    public DirectoryObjectResource<Connection, APIConnection> getConnection()
            throws GuacamoleException {

        // Return the underlying connection as a resource
        return connectionDirectoryResourceFactory
                .create(userContext, userContext.getConnectionDirectory())
                .getObjectResource(activeConnection.getConnectionIdentifier());

    }
577151
public Connection getConnection() throws SQLException {
		Connection connection = this.pool.getConnection();

		// set the Transaction Isolation if defined
		try {
			// set the Transaction Isolation if defined
			if ((this.isolation != null) && (connection.getTransactionIsolation() != this.isolation.intValue())) {
				connection.setTransactionIsolation (this.isolation.intValue());
			}

			// toggle autoCommit to false if set
			if ( connection.getAutoCommit() != this.autocommit ){
				connection.setAutoCommit(this.autocommit);
			}

			return connection;
		} catch (SQLException e){
			try {
				connection.close();
			} catch (Exception e2) {
				logger.warn("Setting connection properties failed and closing this connection failed again", e);
			}

			throw e;
		}
	}
938686
public static ISearch getSearch()
        throws EFapsException
    {
        ISearch ret = null;
        if (EFapsSystemConfiguration.get().containsAttributeValue(KernelSettings.INDEXSEARCHCLASS)) {
            final String clazzname = EFapsSystemConfiguration.get().getAttributeValue(
                            KernelSettings.INDEXSEARCHCLASS);
            try {
                final Class<?> clazz = Class.forName(clazzname, false, EFapsClassLoader.getInstance());
                ret = (ISearch) clazz.newInstance();
            } catch (final ClassNotFoundException | InstantiationException | IllegalAccessException e) {
                throw new EFapsException(Index.class, "Could not instanciate IDirectoryProvider", e);
            }
        } else {
            ret = new ISearch()
            {
                /** The Constant serialVersionUID. */
                private static final long serialVersionUID = 1L;

                /** The query. */
                private String query;

                @Override
                public void setQuery(final String _query)
                {
                    this.query = _query;
                }

                @Override
                public String getQuery()
                {
                    return this.query;
                }
            };
        }
        return ret;
    }
1130877
public SICoreConnection getSICoreConnection()
   {
      if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled()) SibTr.entry(this, tc, "getSICoreConnection");
      if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled()) SibTr.exit(this, tc, "getSICoreConnection", siCoreConnection);
      return siCoreConnection;
   }
5405
public Instance getLink(final String _key)
        throws EFapsException
    {
        return Instance.get(getValue(_key, ConfType.LINK));
    }
1231056
protected Session getSession()
        throws EFapsException
    {
        if (this.session == null) {
            try {
                String username = getProperties().get(JCRStoreResource.PROPERTY_USERNAME);
                if (username == null) {
                    username = Context.getThreadContext().getPerson().getName();
                }
                String passwd = getProperties().get(JCRStoreResource.PROPERTY_PASSWORD);
                if (passwd == null) {
                    passwd = "efaps";
                }
                this.session = this.repository.login(new SimpleCredentials(username, passwd.toCharArray()),
                                getProperties().get(JCRStoreResource.PROPERTY_WORKSPACENAME));
            } catch (final LoginException e) {
                throw new EFapsException(JCRStoreResource.class, "initialize.LoginException", e);
            } catch (final NoSuchWorkspaceException e) {
                throw new EFapsException(JCRStoreResource.class, "initialize.NoSuchWorkspaceException", e);
            } catch (final RepositoryException e) {
                throw new EFapsException(JCRStoreResource.class, "initialize.RepositoryException", e);
            }
        }
        return this.session;
    }
816953
public Long getNextValAsLong()
        throws EFapsException
    {
        long ret = 0;
        try {
            ret = Context.getDbType().nextSequence(Context.getThreadContext().getConnectionResource(),
                            getDBName());
        } catch (final SQLException e) {
            throw new EFapsException(NumberGenerator.class, " getNextValAsLong()", e);
        }
        return ret;
    }
747068
protected Connection<CommPortAdapter> getCommPortConnection()
    {
        Connection<CommPortAdapter> connection=null;
        synchronized(this)
        {
            boolean connectionValid=true;
            //if no connection available
            if(this.commConnection==null)
            {
                connectionValid=false;
            }
            else
            {
                //get adapter
                CommPortAdapter adapter=this.commConnection.getResource();

                //if current adapter is not valid/open
                if(!adapter.isOpen())
                {
                    connectionValid=false;
                }
            }
            
            if(!connectionValid)
            {
                //release old connection
                this.releaseCommPortConnection();

                //create new connection
                this.commConnection=this.createCommPortConnection();
            }
        }
            
        //get connection
        connection=this.commConnection;
        
        return connection;
    }
710512
protected List<Instance> getSuper(final Instance _instance)
        throws EFapsException
    {
        final List<Instance> ret = new ArrayList<>();
        final QueryBuilder queryBldr = new QueryBuilder(getClassName4Type2Type());
        queryBldr.addWhereAttrEqValue(CIAdminProgram.Program2Program.From, _instance.getId());
        final MultiPrintQuery multi = queryBldr.getPrint();
        multi.addAttribute(CIAdminProgram.Program2Program.To);
        multi.execute();
        if (multi.next()) {
            final Instance instance = Instance.get(getClassName4Type().getType(),
                                             multi.<Long>getAttribute(CIAdminProgram.Program2Program.To));
            ret.add(instance);
            ret.addAll(getSuper(instance));
        }
        return ret;
    }
179318
@Override
  public Connection getConnection() throws SQLException {
    return getConnection(
      new Callable<Connection>() {
        @Override
        public Connection call() throws SQLException {
          return MonitoringDataSource.this.original.getConnection();
        }
      },
      ".getConnection");
  }