private ByteBuffer connectClient(String username, String address) {
		ClientConnectionLogRecord record = new ClientConnectionLogRecord(
				address, SystemEvent.CLIENT_CONNECTION,
				"Received connection request from " + address + " for client "
						+ username + ".");
		LOGGER.log(record);

		Connection conn = null;
		try {
			conn = dbConnectionDispatcher.retrieveDatabaseConnection();
			Client tmpClient = FetchClient.execute(username, conn);
			if (tmpClient == null) {
				int clientId = CreateClient.execute(username, true, conn);
				client = new Client(clientId, username, true);

				record = new ClientConnectionLogRecord(address,
						SystemEvent.CLIENT_CONNECTION, "Created client "
								+ username + " in the database.", record);
				LOGGER.log(record);
			} else {
				if (tmpClient.isClientOnline()) {
					RequestResponse failureResponse = new RequestResponse(
							Status.USER_ONLINE);

					record = new ClientConnectionLogRecord(
							address,
							SystemEvent.CLIENT_CONNECTION,
							"Responded to connection request from "
									+ address
									+ " with failure since the specified client "
									+ "is already online.", record);
					LOGGER.log(record);

					return ProtocolMessage.toBytes(failureResponse);
				} else {
					client = tmpClient;
					ChangeClientStatus.execute(username, true, conn);
				}
			}
			connected = true;

			record = new ClientConnectionLogRecord(address,
					SystemEvent.CLIENT_CONNECTION, "Connected client "
							+ username
							+ " successfully, request originated from "
							+ address + ".", record);
			LOGGER.log(record);

			conn.commit();
			RequestResponse successResponse = new RequestResponse(
					Status.SUCCESS);
			return ProtocolMessage.toBytes(successResponse);
		} catch (SQLException e) {
			LOGGER.log(new ClientConnectionLogRecord(address,
					SystemEvent.CLIENT_CONNECTION,
					"Caught exception while trying to connect client from "
							+ address + ".", record, e));

			RequestResponse errorResponse = new RequestResponse(
					Status.EXCEPTION, e.toString());
			if (conn != null)
				try {
					conn.rollback();
				} catch (SQLException e1) {
					logRollbackException(e1);
				}
			return ProtocolMessage.toBytes(errorResponse);
		} finally {
			if (conn != null) {
				try {
					conn.close();
				} catch (SQLException e) {
					logCloseException(e);
				}
			}
		}
	}