private static DBConnection searchConnection() {

		while (true) {

			DBConnection conn = getFreeConnection();

			if (conn != null) {
				conn.setInUse();

				return conn;
			}
			// no free connection found

			if (connections.size() < ConnectionFactory.poolsizeMax) {
				conn = buildConnection();
				connections.add(conn);
				conn.setInUse();

				Loggin.logConnectionFactory("poolsize increased to "
						+ connections.size());

				return conn;
			} else {
				Loggin.logConnectionFactory("pending for connection: max poolsize of '"
						+ ConnectionFactory.poolsizeMax + "' reached");

				waitForConnection();
			}
		}

	}