From cb1c0c043901e1344896d2d0e050711fd30084ff Mon Sep 17 00:00:00 2001 From: harshanl Date: Wed, 16 Dec 2015 15:28:51 +0530 Subject: [PATCH] Fixed DAO connection close issue. --- .../mobile/impl/android/dao/AndroidDAOFactory.java | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/impl/android/dao/AndroidDAOFactory.java b/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/impl/android/dao/AndroidDAOFactory.java index c96bbf437..183a47e64 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/impl/android/dao/AndroidDAOFactory.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/impl/android/dao/AndroidDAOFactory.java @@ -83,16 +83,15 @@ public class AndroidDAOFactory extends AbstractMobileDeviceManagementDAOFactory } } catch (SQLException e) { throw new MobileDeviceManagementDAOException("Error occurred while committing the transaction", e); - } finally { - closeConnection(); } } public static void closeConnection() throws MobileDeviceManagementDAOException { - - Connection con = currentConnection.get(); + Connection conn = currentConnection.get(); try { - con.close(); + if (conn != null) { + conn.close(); + } } catch (SQLException e) { log.error("Error occurred while close the connection"); } @@ -112,8 +111,6 @@ public class AndroidDAOFactory extends AbstractMobileDeviceManagementDAOFactory } } catch (SQLException e) { throw new MobileDeviceManagementDAOException("Error occurred while rollback the transaction", e); - } finally { - closeConnection(); } }