public int GetCommand(int devID) throws Exception {
		int command = -1;

		try {
			// This will load the MySQL driver, each DB has its own driver
			Class.forName("com.mysql.jdbc.Driver");
			// Setup the connection with the DB
			_connect = DriverManager.getConnection(_url, _user, _password);
			// PreparedStatements can use variables and are more efficient
			String sql = "SELECT * FROM command_queue WHERE time_entered = ( SELECT MIN(time_entered) FROM command_queue WHERE devices_id = ? AND time_executed IS NULL)";
			_preparedStatement = _connect.prepareStatement(sql);
			_preparedStatement.setInt(1, devID);
			_resultSet = _preparedStatement.executeQuery();

			if (_resultSet.next()) {
				int id = _resultSet.getInt("id");
				command = _resultSet.getInt("commands_id");

				sql = "UPDATE command_queue SET time_executed = ? WHERE id = ?";
				_preparedStatement = _connect.prepareStatement(sql);
				_preparedStatement.setTimestamp(1,
						new Timestamp(System.currentTimeMillis()));
				_preparedStatement.setInt(2, id);
				_preparedStatement.executeUpdate();
			}

		} catch (Exception e) {
			throw e;
		} finally {
			close();
		}

		return command;
	}