Example usage for java.sql PreparedStatement setQueryTimeout

List of usage examples for java.sql PreparedStatement setQueryTimeout

Introduction

In this page you can find the example usage for java.sql PreparedStatement setQueryTimeout.

Prototype

void setQueryTimeout(int seconds) throws SQLException;

Source Link

Document

Sets the number of seconds the driver will wait for a Statement object to execute to the given number of seconds.

Usage

From source file:com.u2apple.rt.db.dao.DeviceDao.java

public List<AndroidDeviceRanking> queryByBrand(String brand) throws SQLException {
    List<AndroidDeviceRanking> devices = new ArrayList<>();
    Connection connection = null;
    PreparedStatement statement = null;
    ResultSet rs = null;/*from w w  w.java 2 s.com*/
    try {
        connection = Pool.getStatConnection();
        String sql = SqlUtils.createMonthlyQuery(QUERY_BY_BRAND, "log_device_init");
        statement = connection.prepareStatement(sql);
        statement.setString(1, brand);
        statement.setQueryTimeout(Constants.TIMEOUT_LONG);
        rs = statement.executeQuery();
        while (rs.next()) {
            AndroidDeviceRanking device = new AndroidDeviceRanking();
            String vid = rs.getString("vid");
            String roProductModel = rs.getString("ro_product_model");
            int count = rs.getInt("count");

            device.setVid(vid);
            device.setRoProductModel(roProductModel);
            device.setCount(count);
            devices.add(device);
        }
    } catch (JSchException | ClassNotFoundException | PropertyVetoException | IOException ex) {
        logger.error("SQL fail", ex);
    } finally {
        try {
            if (rs != null) {
                rs.close();
            }
            if (statement != null) {
                statement.close();
            }
            if (connection != null) {
                connection.close();
            }
        } catch (SQLException ex) {
            logger.error("Fail when conection was closed", ex);
        }
    }
    return devices;
}

From source file:com.u2apple.rt.db.dao.DeviceDao.java

public List<AndroidDevice> queryByModel(String model) {
    List<AndroidDevice> devices = new ArrayList<>();
    Connection connection = null;
    PreparedStatement statement = null;
    ResultSet rs = null;/*w  ww . j  a  v  a2 s.co m*/
    try {
        connection = Pool.getStatConnection();
        String sql = SqlUtils.createMonthlyQuery(QUERY_BY_MODEL_SQL, "log_device_init");
        statement = connection.prepareStatement(sql);
        statement.setString(1, model);
        statement.setQueryTimeout(Constants.TIMEOUT_SHORT);
        rs = statement.executeQuery();
        while (rs.next()) {
            AndroidDevice device = new AndroidDevice();
            String vid = rs.getString("vid");
            String roProductModel = rs.getString("ro_product_model");
            String brand = rs.getString("ro_product_brand");
            String productId = rs.getString("product_id");
            device.setVid(vid);
            device.setRoProductBrand(brand);
            device.setRoProductModel(roProductModel);
            device.setProductId(productId);
            devices.add(device);
        }
    } catch (SQLException | JSchException | ClassNotFoundException | PropertyVetoException | IOException ex) {
        logger.error("SQL fail", ex);
    } finally {
        try {
            if (rs != null) {
                rs.close();
            }
            if (statement != null) {
                statement.close();
            }
            if (connection != null) {
                connection.close();
            }
        } catch (SQLException ex) {
            logger.error("Fail when conection was closed", ex);
        }
    }
    return devices;
}

From source file:com.u2apple.rt.db.dao.DeviceDao.java

public List<AndroidDevice> queryLikeModel(String model) {
    List<AndroidDevice> devices = new ArrayList<>();
    Connection connection = null;
    PreparedStatement statement = null;
    ResultSet rs = null;//  w w  w  . j a va2  s.  c  o m
    try {
        connection = Pool.getStatConnection();
        String sql = SqlUtils.createMonthlyQuery(QUERY_LIKE_MODEL_SQL, "log_device_init");
        statement = connection.prepareStatement(sql);
        statement.setString(1, "%" + model.toLowerCase() + "%");
        statement.setQueryTimeout(Constants.TIMEOUT_SHORT);
        rs = statement.executeQuery();
        while (rs.next()) {
            AndroidDevice device = new AndroidDevice();
            String vid = rs.getString("vid");
            String roProductModel = rs.getString("ro_product_model");
            String brand = rs.getString("ro_product_brand");
            String productId = rs.getString("product_id");
            device.setVid(vid);
            device.setRoProductBrand(brand);
            device.setRoProductModel(roProductModel);
            device.setProductId(productId);
            devices.add(device);
        }
    } catch (SQLException | JSchException | ClassNotFoundException | PropertyVetoException | IOException ex) {
        logger.error("SQL fail", ex);
    } finally {
        try {
            if (rs != null) {
                rs.close();
            }
            if (statement != null) {
                statement.close();
            }
            if (connection != null) {
                connection.close();
            }
        } catch (SQLException ex) {
            logger.error("Fail when conection was closed", ex);
        }
    }
    return devices;
}

From source file:com.base2.kagura.core.report.connectors.FreemarkerSQLDataReportConnector.java

/**
 * Runs freemarker against the 3 sql queries, then executes them in order.
 * {@inheritDoc}//from   w w w  .j a va2 s .  co  m
 */
@Override
public void runReport(Map<String, Object> extra) {
    PreparedStatement prestatement = null;
    PreparedStatement poststatement = null;
    PreparedStatement statement = null;
    try {
        getStartConnection();
        if (StringUtils.isNotBlank(presql)) {
            FreemarkerSQLResult prefreemarkerSQLResult = freemakerParams(extra, false, presql);
            prestatement = connection.prepareStatement(prefreemarkerSQLResult.getSql());
            for (int i = 0; i < prefreemarkerSQLResult.getParams().size(); i++) {
                prestatement.setObject(i + 1, prefreemarkerSQLResult.getParams().get(i));
            }
            prestatement.setQueryTimeout(queryTimeout);
            prestatement.execute();
        }
        FreemarkerSQLResult freemarkerSQLResult = freemakerParams(extra, true, freemarkerSql);
        statement = connection.prepareStatement(freemarkerSQLResult.getSql());
        for (int i = 0; i < freemarkerSQLResult.getParams().size(); i++) {
            statement.setObject(i + 1, freemarkerSQLResult.getParams().get(i));
        }
        statement.setQueryTimeout(queryTimeout);
        rows = resultSetToMap(statement.executeQuery());
        if (StringUtils.isNotBlank(postsql)) {
            FreemarkerSQLResult postfreemarkerSQLResult = freemakerParams(extra, false, postsql);
            poststatement = connection.prepareStatement(postfreemarkerSQLResult.getSql());
            for (int i = 0; i < postfreemarkerSQLResult.getParams().size(); i++) {
                poststatement.setObject(i + 1, postfreemarkerSQLResult.getParams().get(i));
            }
            poststatement.setQueryTimeout(queryTimeout);
            poststatement.execute();
        }
    } catch (Exception ex) {
        errors.add(ex.getMessage());
    } finally {
        try {
            if (statement != null && !statement.isClosed()) {
                statement.close();
                statement = null;
            }
            if (prestatement != null && !prestatement.isClosed()) {
                prestatement.close();
                prestatement = null;
            }
            if (poststatement != null && !poststatement.isClosed()) {
                poststatement.close();
                poststatement = null;
            }
            if (connection != null && !connection.isClosed()) {
                connection.close();
                connection = null;
            }
        } catch (SQLException e) {
            errors.add(e.getMessage());
            e.printStackTrace();
        }
    }
}

From source file:com.u2apple.rt.db.dao.DeviceDao.java

public List<AndroidDevice> queryByMacAddress(String macAddr, int limit) throws SQLException {
    List<AndroidDevice> devices = new ArrayList<>();
    Connection connection = null;
    PreparedStatement statement = null;
    ResultSet rs = null;//from w  w  w . ja  va 2 s.com
    try {
        connection = Pool.getStatConnection();
        String sql = SqlUtils.createMonthlyQuery(QUERY_BY_MAC_ADDRESS_SQL, "log_device_init_full");
        statement = connection.prepareStatement(sql);
        statement.setString(1, macAddr);
        statement.setInt(2, limit);
        statement.setQueryTimeout(Constants.TIMEOUT_SHORT);
        rs = statement.executeQuery();
        while (rs.next()) {
            AndroidDevice device = new AndroidDevice();
            String macAddress = rs.getString("mac_address");
            String vid = rs.getString("vid");
            String pid = rs.getString("pid");
            String prot = rs.getString("prot");
            String sn = rs.getString("sn");
            String adbDevice = rs.getString("adb_device");
            String productId = rs.getString("product_id");
            String toProductDevice = rs.getString("ro_product_device");
            String roProductModel = rs.getString("ro_product_model");
            String brand = rs.getString("ro_product_brand");
            String roProductBoard = rs.getString("ro_product_board");
            String roProductManufacturer = rs.getString("ro_product_manufacturer");
            String roHardware = rs.getString("ro_hardware");
            String roBuildDisplayId = rs.getString("ro_build_display_id");
            String customProps = rs.getString("custom_props");
            String createdAt = rs.getString("created_at");
            String returnProductId = rs.getString("return_product_id");
            String identified = rs.getString("identified");
            String androidVersion = rs.getString("android_version");
            String cpuHardware = rs.getString("cpu_hardware");
            //Add more properties.
            String resolution = rs.getString("resolution");
            String partition = rs.getString("partitions");

            device.setMacAddress(macAddress);
            device.setPid(pid);
            device.setProt(prot);
            device.setSn(sn);
            device.setAdbDevice(adbDevice);
            device.setRoProductDevice(toProductDevice);
            device.setRoProductBoard(roProductBoard);
            device.setRoProductManufacturer(roProductManufacturer);
            device.setRoHardware(roHardware);
            device.setRoBuildDisplayId(roBuildDisplayId);
            device.setCustomProps(customProps);
            device.setCreatedAt(createdAt);
            device.setReturnProductId(returnProductId);
            device.setIdentified(identified);
            device.setVid(vid);
            device.setRoProductBrand(brand);
            device.setRoProductModel(roProductModel);
            device.setProductId(productId);
            device.setAndroidVersion(androidVersion);
            device.setCpuHardware(cpuHardware);
            //Add more properties
            device.setResolution(resolution);
            device.setPartitions(partition);
            devices.add(device);
        }
    } catch (JSchException | ClassNotFoundException | PropertyVetoException | IOException ex) {
        logger.error("SQL fail", ex);
    } finally {
        try {
            if (rs != null) {
                rs.close();
            }
            if (statement != null) {
                statement.close();
            }
            if (connection != null) {
                connection.close();
            }
        } catch (SQLException ex) {
            logger.error("Fail when conection was closed", ex);
        }
    }
    return devices;
}

From source file:com.u2apple.tool.dao.DeviceDao.java

@Deprecated
public List<AndroidDeviceRanking> listModes() throws SQLException {
    List<AndroidDeviceRanking> devices = new ArrayList<>();
    Connection connection = null;
    PreparedStatement statement = null;
    ResultSet rs = null;/*from  w w w  .jav a2  s  .  co  m*/
    try {
        connection = Pool.getStatConnection();
        String sql = SqlUtils.createMonthlyQuery(MODEL_AND_PRODUCT_ID_ANALYTICS_SQL, "log_device_init");
        statement = connection.prepareStatement(sql);
        statement.setQueryTimeout(Constants.TIMEOUT_LONG);
        rs = statement.executeQuery();
        while (rs.next()) {
            AndroidDeviceRanking device = new AndroidDeviceRanking();
            String productId = rs.getString("return_product_id");
            String roProductModel = rs.getString("ro_product_model");
            int count = rs.getInt("count");

            device.setProductId(productId);
            device.setRoProductModel(roProductModel);
            device.setCount(count);
            devices.add(device);
        }
    } catch (JSchException | ClassNotFoundException | PropertyVetoException | IOException ex) {
        logger.error("SQL fail", ex);
    } finally {
        try {
            if (rs != null) {
                rs.close();
            }
            if (statement != null) {
                statement.close();
            }
            if (connection != null) {
                connection.close();
            }
        } catch (SQLException ex) {
            logger.error("Fail when conection was closed", ex);
        }
    }
    return devices;
}

From source file:com.u2apple.rt.db.dao.DeviceDao.java

public List<AndroidDevice> queryByVidAndModel(String aVid, String model, int limit) throws SQLException {
    List<AndroidDevice> devices = new ArrayList<>();
    Connection connection = null;
    PreparedStatement statement = null;
    ResultSet rs = null;/* w w w.ja  va  2 s .com*/
    try {
        connection = Pool.getStatConnection();
        String sql = SqlUtils.createMonthlyQuery(DEVICE_DETAIL_SQL, "log_device_init");
        statement = connection.prepareStatement(sql);
        statement.setString(1, model);
        statement.setString(2, aVid);
        statement.setInt(3, limit);
        statement.setQueryTimeout(Constants.TIMEOUT_SHORT);
        rs = statement.executeQuery();
        while (rs.next()) {
            AndroidDevice device = new AndroidDevice();
            String macAddress = rs.getString("mac_address");
            String vid = rs.getString("vid");
            String pid = rs.getString("pid");
            String prot = rs.getString("prot");
            String sn = rs.getString("sn");
            String adbDevice = rs.getString("adb_device");
            String productId = rs.getString("product_id");
            String toProductDevice = rs.getString("ro_product_device");
            String roProductModel = rs.getString("ro_product_model");
            String brand = rs.getString("ro_product_brand");
            String roProductBoard = rs.getString("ro_product_board");
            String roProductManufacturer = rs.getString("ro_product_manufacturer");
            String roHardware = rs.getString("ro_hardware");
            String roBuildDisplayId = rs.getString("ro_build_display_id");
            String customProps = rs.getString("custom_props");
            String createdAt = rs.getString("created_at");
            String returnProductId = rs.getString("return_product_id");
            String identified = rs.getString("identified");
            String androidVersion = rs.getString("android_version");
            String cpuHardware = rs.getString("cpu_hardware");

            device.setMacAddress(macAddress);
            device.setPid(pid);
            device.setProt(prot);
            device.setSn(sn);
            device.setAdbDevice(adbDevice);
            device.setRoProductDevice(toProductDevice);
            device.setRoProductBoard(roProductBoard);
            device.setRoProductManufacturer(roProductManufacturer);
            device.setRoHardware(roHardware);
            device.setRoBuildDisplayId(roBuildDisplayId);
            device.setCustomProps(customProps);
            device.setCreatedAt(createdAt);
            device.setReturnProductId(returnProductId);
            device.setIdentified(identified);
            device.setVid(vid);
            device.setRoProductBrand(brand);
            device.setRoProductModel(roProductModel);
            device.setProductId(productId);
            device.setAndroidVersion(androidVersion);
            device.setCpuHardware(cpuHardware);
            devices.add(device);
        }
    } catch (JSchException | ClassNotFoundException | PropertyVetoException | IOException ex) {
        logger.error("SQL fail", ex);
    } finally {
        try {
            if (rs != null) {
                rs.close();
            }
            if (statement != null) {
                statement.close();
            }
            if (connection != null) {
                connection.close();
            }
        } catch (SQLException ex) {
            logger.error("Fail when conection was closed", ex);
        }
    }
    return devices;
}

From source file:com.u2apple.rt.db.dao.DeviceDao.java

public List<AndroidDevice> queryAllDetailByVidAndModel(String aVid, String model, int limit)
        throws SQLException {
    List<AndroidDevice> devices = new ArrayList<>();
    Connection connection = null;
    PreparedStatement statement = null;
    ResultSet rs = null;/*from  w  ww  .ja va2  s.c  o  m*/
    try {
        connection = Pool.getStatConnection();
        String sql = SqlUtils.createMonthlyQuery(DEVICE_ALL_DETAIL_SQL, "log_device_init_full");
        statement = connection.prepareStatement(sql);
        statement.setString(1, model);
        statement.setString(2, aVid);
        statement.setInt(3, limit);
        statement.setQueryTimeout(Constants.TIMEOUT_SHORT);
        rs = statement.executeQuery();
        while (rs.next()) {
            AndroidDevice device = new AndroidDevice();
            String macAddress = rs.getString("mac_address");
            String vid = rs.getString("vid");
            String pid = rs.getString("pid");
            String prot = rs.getString("prot");
            String sn = rs.getString("sn");
            String adbDevice = rs.getString("adb_device");
            String productId = rs.getString("product_id");
            String toProductDevice = rs.getString("ro_product_device");
            String roProductModel = rs.getString("ro_product_model");
            String brand = rs.getString("ro_product_brand");
            String roProductBoard = rs.getString("ro_product_board");
            String roProductManufacturer = rs.getString("ro_product_manufacturer");
            String roHardware = rs.getString("ro_hardware");
            String roBuildDisplayId = rs.getString("ro_build_display_id");
            String customProps = rs.getString("custom_props");
            String createdAt = rs.getString("created_at");
            String returnProductId = rs.getString("return_product_id");
            String identified = rs.getString("identified");
            String androidVersion = rs.getString("android_version");
            String cpuHardware = rs.getString("cpu_hardware");
            //Add more properties.
            String resolution = rs.getString("resolution");
            String partition = rs.getString("partitions");

            device.setMacAddress(macAddress);
            device.setPid(pid);
            device.setProt(prot);
            device.setSn(sn);
            device.setAdbDevice(adbDevice);
            device.setRoProductDevice(toProductDevice);
            device.setRoProductBoard(roProductBoard);
            device.setRoProductManufacturer(roProductManufacturer);
            device.setRoHardware(roHardware);
            device.setRoBuildDisplayId(roBuildDisplayId);
            device.setCustomProps(customProps);
            device.setCreatedAt(createdAt);
            device.setReturnProductId(returnProductId);
            device.setIdentified(identified);
            device.setVid(vid);
            device.setRoProductBrand(brand);
            device.setRoProductModel(roProductModel);
            device.setProductId(productId);
            device.setAndroidVersion(androidVersion);
            device.setCpuHardware(cpuHardware);
            //Add more properties
            device.setResolution(resolution);
            device.setPartitions(partition);
            devices.add(device);
        }
    } catch (JSchException | ClassNotFoundException | PropertyVetoException | IOException ex) {
        logger.error("SQL fail", ex);
    } finally {
        try {
            if (rs != null) {
                rs.close();
            }
            if (statement != null) {
                statement.close();
            }
            if (connection != null) {
                connection.close();
            }
        } catch (SQLException ex) {
            logger.error("Fail when conection was closed", ex);
        }
    }
    return devices;
}

From source file:com.u2apple.tool.dao.DeviceDao.java

public List<AndroidDevice> queryByVidAndModel(String aVid, String pBrand, String model, int limit)
        throws SQLException {
    List<AndroidDevice> devices = new ArrayList<>();
    Connection connection = null;
    PreparedStatement statement = null;
    ResultSet rs = null;// ww  w  . j a  va 2 s.  c o m
    try {
        connection = Pool.getStatConnection();
        String sql = SqlUtils.createMonthlyQuery(DEVICE_DETAIL_SQL, "log_device_init");
        statement = connection.prepareStatement(sql);
        statement.setString(1, model);
        statement.setString(2, aVid);
        statement.setString(3, pBrand);
        statement.setInt(4, limit);
        statement.setQueryTimeout(Constants.TIMEOUT_SHORT);
        rs = statement.executeQuery();
        while (rs.next()) {
            AndroidDevice device = new AndroidDevice();
            String macAddress = rs.getString("mac_address");
            String vid = rs.getString("vid");
            String pid = rs.getString("pid");
            String prot = rs.getString("prot");
            String sn = rs.getString("sn");
            String adbDevice = rs.getString("adb_device");
            String productId = rs.getString("product_id");
            String toProductDevice = rs.getString("ro_product_device");
            String roProductModel = rs.getString("ro_product_model");
            String brand = rs.getString("ro_product_brand");
            String roProductBoard = rs.getString("ro_product_board");
            String roProductManufacturer = rs.getString("ro_product_manufacturer");
            String roHardware = rs.getString("ro_hardware");
            String roBuildDisplayId = rs.getString("ro_build_display_id");
            String customProps = rs.getString("custom_props");
            String createdAt = rs.getString("created_at");
            String returnProductId = rs.getString("return_product_id");
            String identified = rs.getString("identified");
            String androidVersion = rs.getString("android_version");
            String cpuHardware = rs.getString("cpu_hardware");
            String roProductName = rs.getString("ro_product_name");
            String roBuildFingerprint = rs.getString("ro_build_fingerprint");

            device.setMacAddress(macAddress);
            device.setPid(pid);
            device.setProt(prot);
            device.setSn(sn);
            device.setAdbDevice(adbDevice);
            device.setRoProductDevice(toProductDevice);
            device.setRoProductBoard(roProductBoard);
            device.setRoProductManufacturer(roProductManufacturer);
            device.setRoHardware(roHardware);
            device.setRoBuildDisplayId(roBuildDisplayId);
            device.setCustomProps(customProps);
            device.setCreatedAt(createdAt);
            device.setReturnProductId(returnProductId);
            device.setIdentified(identified);
            device.setVid(vid);
            device.setRoProductBrand(brand);
            device.setRoProductModel(roProductModel);
            device.setProductId(productId);
            device.setAndroidVersion(androidVersion);
            device.setCpuHardware(cpuHardware);
            device.setRoProductName(roProductName);
            device.setRoBuildFingerprint(roBuildFingerprint);
            devices.add(device);
        }
    } catch (JSchException | ClassNotFoundException | PropertyVetoException | IOException ex) {
        logger.error("SQL fail", ex);
    } finally {
        try {
            if (rs != null) {
                rs.close();
            }
            if (statement != null) {
                statement.close();
            }
            if (connection != null) {
                connection.close();
            }
        } catch (SQLException ex) {
            logger.error("Fail when conection was closed", ex);
        }
    }
    return devices;
}

From source file:com.u2apple.tool.dao.DeviceDao.java

public List<AndroidDevice> queryByVidAndModelForShuameMobile(String aVid, String pBrand, String model,
        int limit) throws SQLException {
    List<AndroidDevice> devices = new ArrayList<>();
    Connection connection = null;
    PreparedStatement statement = null;
    ResultSet rs = null;//ww w.jav a2  s  . c  o m
    try {
        connection = Pool.getStatConnection();
        String sql = SqlUtils.createMonthlyQuery(DEVICE_DETAIL_OF_SHUAME_MOBILE_SQL, "log_m_device_init");
        statement = connection.prepareStatement(sql);
        statement.setString(1, model);
        statement.setString(2, aVid);
        statement.setString(3, pBrand);
        statement.setInt(4, limit);
        statement.setQueryTimeout(Constants.TIMEOUT_SHORT);
        rs = statement.executeQuery();
        while (rs.next()) {
            AndroidDevice device = new AndroidDevice();
            String macAddress = rs.getString("mac_address");
            String vid = rs.getString("vid");
            String pid = rs.getString("pid");
            String prot = rs.getString("prot");
            String sn = rs.getString("sn");
            String productId = rs.getString("product_id");
            String toProductDevice = rs.getString("ro_product_device");
            String roProductModel = rs.getString("ro_product_model");
            String brand = rs.getString("ro_product_brand");
            String roProductBoard = rs.getString("ro_product_board");
            String roProductManufacturer = rs.getString("ro_product_manufacturer");
            String roHardware = rs.getString("ro_hardware");
            String customProps = rs.getString("custom_props");
            String createdAt = rs.getString("created_at");
            String returnProductId = rs.getString("return_product_id");
            String identified = rs.getString("identified");
            String androidVersion = rs.getString("android_version");
            String cpuHardware = rs.getString("cpu_hardware");
            String roProductName = rs.getString("ro_product_name");
            String roBuildFingerprint = rs.getString("ro_build_fingerprint");

            device.setMacAddress(macAddress);
            device.setPid(pid);
            device.setProt(prot);
            device.setSn(sn);
            device.setRoProductDevice(toProductDevice);
            device.setRoProductBoard(roProductBoard);
            device.setRoProductManufacturer(roProductManufacturer);
            device.setRoHardware(roHardware);
            device.setCustomProps(customProps);
            device.setCreatedAt(createdAt);
            device.setReturnProductId(returnProductId);
            device.setIdentified(identified);
            device.setVid(vid);
            device.setRoProductBrand(brand);
            device.setRoProductModel(roProductModel);
            device.setProductId(productId);
            device.setAndroidVersion(androidVersion);
            device.setCpuHardware(cpuHardware);
            device.setRoProductName(roProductName);
            device.setRoBuildFingerprint(roBuildFingerprint);
            devices.add(device);
        }
    } catch (JSchException | ClassNotFoundException | PropertyVetoException | IOException ex) {
        logger.error("SQL fail", ex);
    } finally {
        try {
            if (rs != null) {
                rs.close();
            }
            if (statement != null) {
                statement.close();
            }
            if (connection != null) {
                connection.close();
            }
        } catch (SQLException ex) {
            logger.error("Fail when conection was closed", ex);
        }
    }
    return devices;
}