Creates and returns the mail connection to be used to send the fax
via mail.

@return  The mail connection
347158
protected Connection<MailResourcesHolder> createMailConnection()
    {
        //create new connection
        Connection<MailResourcesHolder> mailConnection=this.connectionFactory.createConnection();

        //log debug
        Logger logger=this.getLogger();
        logger.logInfo(new Object[]{"Created mail connection."},null);

        return mailConnection;
    }
1131974
protected void sendMail(FaxJob faxJob,Connection<MailResourcesHolder> mailConnection,Message message)
    {
        if(message==null)
        {
            this.throwUnsupportedException();
        }
        else
        {
            //get holder
            MailResourcesHolder mailResourcesHolder=mailConnection.getResource();

            //get transport
            Transport transport=mailResourcesHolder.getTransport();
            
            try
            {
                //send message
                message.saveChanges();
                if(transport==null)
                {
                    Transport.send(message,message.getAllRecipients());
                }
                else
                {
                    transport.sendMessage(message,message.getAllRecipients());
                }
            }
            catch(Throwable throwable)
            {
                throw new FaxException("Unable to send message.",throwable);
            }
            finally
            {
                if(!this.usePersistentConnection)
                {
                    try
                    {
                        //close connection
                        this.closeMailConnection(mailConnection);
                    }
                    catch(Exception exception)
                    {
                        //log error
                        Logger logger=this.getLogger();
                        logger.logInfo(new Object[]{"Error while releasing mail connection."},exception);
                    }
                }
            }
        }
    }
607524
public Connection<T> createConnection()
    {
        //log info
        this.LOGGER.logInfo(new Object[]{"Opening a new connection from factory type: ",this.getClass().getName()},null);

        //create resource
        T resource=this.createResourceImpl();
        if(resource==null)
        {
            throw new FaxException("Unable to create resource.");
        }

        //create connection
        Connection<T> connection=this.createConnectionForResource(resource);

        //register connection
        CloseableResourceManager.registerCloseable(connection);

        //log info
        this.LOGGER.logInfo(new Object[]{"New connection opened."},null);
        
        return connection;
    }
531005
protected SICoreConnection createConnection() throws SIResourceException {
        if (TraceComponent.isAnyTracingEnabled()
            && tc.isEntryEnabled())
            SibTr.entry(tc, "createConnection");

        SICoreConnection newConn = new ConnectionImpl(this, null, null);

        // Lock the connections so that we can't be stopped midway through a
        // create
        _connectionsLockManager.lock();

        try {
            // Now we have a lock make sure we are started.
            checkStarted();

            synchronized (_connections) {
                _connections.put(newConn, newConn);
            }
        } finally {
            _connectionsLockManager.unlock();
        }

        if (TraceComponent.isAnyTracingEnabled()
            && tc.isEntryEnabled())
            SibTr.exit(tc, "createConnection", newConn);

        return newConn;
    }
1114875
public Connection createDBConnection() {
        if (mDBConnInfo != null) {
            return getConnectionViaDriverMangaer(mDBConnInfo.DBDriver, mDBConnInfo.DBUrl, mDBConnInfo.DBUser, mDBConnInfo.DBPassword);
        } else {
            return null;
        }
    }
483790
public DbConn getConn()
    {
        Connection cnx = null;
        try
        {
            Thread.interrupted(); // this is VERY sad. Needed for Oracle driver which otherwise fails spectacularly.
            cnx = _ds.getConnection();
            if (cnx.getAutoCommit())
            {
                cnx.setAutoCommit(false);
                cnx.rollback(); // To ensure no open transaction created by the pool before changing TX mode
            }

            if (cnx.getTransactionIsolation() != Connection.TRANSACTION_READ_COMMITTED)
            {
                cnx.setTransactionIsolation(Connection.TRANSACTION_READ_COMMITTED);
            }

            return new DbConn(this, cnx);
        }
        catch (SQLException e)
        {
            DbHelper.closeQuietly(cnx); // May have been left open when the pool has given us a failed connection.
            throw new DatabaseException(e);
        }
    }
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();
     }
1324154
@Override
	public Connection getConnection() {
		try {
			String jdbcUrl = props.get(PROPS_JDBC_URL);
			String jdbcUser = props.get(PROPS_JDBC_USER);
			String jdbcPassword = props.get(PROPS_JDBC_PASSWORD);

			Connection connection = DriverManager.getConnection(jdbcUrl, jdbcUser, jdbcPassword);

			String schema = getSchema();
			if (schema != null) {
				connection.setSchema(schema);
			}
			connection.setAutoCommit(getAutoCommit());
			connection.setReadOnly(getReadOnly());
			int transactionIsolation = getTransactionIsolation();
			if (transactionIsolation > 0) {
				connection.setTransactionIsolation(transactionIsolation);
			}
			return connection;
		} catch (SQLException ex) {
			ex.printStackTrace();
			return null;
		}
	}
996451
public static Connection getconnnection() {
		Connection con = null;
		try {
			con = DriverManager.getConnection(url, userName, password);
		} catch (SQLException e) {
			e.printStackTrace();
		}
		return con;
	}
1115916
private Session createConnection() {

        /* reorder locations */
        List<String> locations = Lists.newArrayList(split.getReplicas());
        Collections.sort(locations, new DeepPartitionLocationComparator());

        Exception lastException = null;

        LOG.debug("createConnection: " + locations);
        for (String location : locations) {

            try {
                return trySessionForLocation(location, config, false).left;
            } catch (Exception e) {
                LOG.error("Could not get connection for: {}, replicas: {}", location, locations);
                lastException = e;
            }
        }

        throw new DeepIOException(lastException);
    }
150288
protected synchronized HylaFAXClient getHylaFAXClient()
    {
        HylaFAXClient client=null;
        if(this.connection==null)
        {
            //create new connection
            this.connection=this.connectionFactory.createConnection();
        }
        
        //get client
        client=this.connection.getResource();
        
        return client;
    }
803207
public function getConnection()
	{
		if ($this->connection) return $this->connection;

		return $this->connection = new Net_SFTP($this->host, $this->port);
	}
745219
Connection getSingleConnection() {
        Connection connection = null;
        try {
            Class.forName(driver);
            connection = DriverManager.getConnection(url, user, password);
        } catch (SQLException e) {
            throw new InitializationException("Could not initialize the connection", e);
        } catch (ClassNotFoundException e) {
            throw new InitializationException("Could not find the driver class", e);
        }
        return connection;
    }
895187
protected FaxJob createFaxJobImpl()
    {
        //create new fax job
        FaxJob faxJob=new FaxJobImpl();
        
        //set defaults
        faxJob.setPriority(FaxJobPriority.MEDIUM_PRIORITY);
        
        return faxJob;
    }
1024197
public Email to(String... to) {
		for (String t : to) {
			to(new EmailAddress(t));
		}
		return this;
	}
912705
protected final FaxModemAdapter createFaxModemAdapter()
    {
        //create new instance
        FaxModemAdapter adapter=(FaxModemAdapter)ReflectionHelper.createInstance(this.faxModemClassName);
            
        //initialize
        adapter.initialize(this);
        
        return adapter;
    }
558613
private CompletableFuture<Connection> connect() {
    // If the address selector has been reset then reset the connection.
    if (selector.state() == AddressSelector.State.RESET && connection != null) {
      if (connectFuture != null) {
        return connectFuture;
      }

      CompletableFuture<Connection> future = new OrderedCompletableFuture<>();
      future.whenComplete((r, e) -> this.connectFuture = null);
      this.connectFuture = future;

      Connection oldConnection = this.connection;
      this.connection = null;
      oldConnection.close();
      connect(future);
      return future;
    }

    // If a connection was already established then use that connection.
    if (connection != null) {
      return CompletableFuture.completedFuture(connection);
    }

    // If a connection is currently being established then piggyback on the connect future.
    if (connectFuture != null) {
      return connectFuture;
    }

    // Create a new connect future and connect to the first server in the cluster.
    CompletableFuture<Connection> future = new OrderedCompletableFuture<>();
    future.whenComplete((r, e) -> this.connectFuture = null);
    this.connectFuture = future;
    reset().connect(future);
    return future;
  }