Merge branch 'master' of github.com:wso2/carbon-device-mgt-plugins

revert-dabc3590
Dulitha Wijewantha 10 years ago
commit 95b14165d5

@ -50,8 +50,10 @@ public class AndroidFeatureDAOImpl implements MobileFeatureDAO {
MobileDeviceManagementDAOException { MobileDeviceManagementDAOException {
PreparedStatement stmt = null; PreparedStatement stmt = null;
boolean status = false; boolean status = false;
Connection conn = null;
try { try {
Connection conn = this.getConnection(); conn = this.getConnection();
String sql = "INSERT INTO AD_FEATURE(CODE, NAME, DESCRIPTION) VALUES (?, ?, ?)"; String sql = "INSERT INTO AD_FEATURE(CODE, NAME, DESCRIPTION) VALUES (?, ?, ?)";
stmt = conn.prepareStatement(sql); stmt = conn.prepareStatement(sql);
stmt.setString(1, mobileFeature.getCode()); stmt.setString(1, mobileFeature.getCode());
@ -65,7 +67,7 @@ public class AndroidFeatureDAOImpl implements MobileFeatureDAO {
"Error occurred while adding android feature '" + "Error occurred while adding android feature '" +
mobileFeature.getName() + "' into the metadata repository", e); mobileFeature.getName() + "' into the metadata repository", e);
} finally { } finally {
MobileDeviceManagementDAOUtil.cleanupResources(stmt, null); MobileDeviceManagementDAOUtil.cleanupResources(conn, stmt, null);
} }
return status; return status;
} }
@ -110,8 +112,9 @@ public class AndroidFeatureDAOImpl implements MobileFeatureDAO {
public boolean deleteFeatureById(int mblFeatureId) throws MobileDeviceManagementDAOException { public boolean deleteFeatureById(int mblFeatureId) throws MobileDeviceManagementDAOException {
PreparedStatement stmt = null; PreparedStatement stmt = null;
boolean status = false; boolean status = false;
Connection conn = null;
try { try {
Connection conn = this.getConnection(); conn = this.getConnection();
String sql = "DELETE FROM AD_FEATURE WHERE ID = ?"; String sql = "DELETE FROM AD_FEATURE WHERE ID = ?";
stmt = conn.prepareStatement(sql); stmt = conn.prepareStatement(sql);
stmt.setInt(1, mblFeatureId); stmt.setInt(1, mblFeatureId);
@ -122,7 +125,7 @@ public class AndroidFeatureDAOImpl implements MobileFeatureDAO {
"Error occurred while deleting android feature '" + "Error occurred while deleting android feature '" +
mblFeatureId + "' from Android database.", e); mblFeatureId + "' from Android database.", e);
} finally { } finally {
MobileDeviceManagementDAOUtil.cleanupResources(stmt, null); MobileDeviceManagementDAOUtil.cleanupResources(conn, stmt, null);
} }
return status; return status;
} }
@ -132,8 +135,9 @@ public class AndroidFeatureDAOImpl implements MobileFeatureDAO {
MobileDeviceManagementDAOException { MobileDeviceManagementDAOException {
PreparedStatement stmt = null; PreparedStatement stmt = null;
boolean status = false; boolean status = false;
Connection conn = null;
try { try {
Connection conn = this.getConnection(); conn = this.getConnection();
String sql = "DELETE FROM AD_FEATURE WHERE CODE = ?"; String sql = "DELETE FROM AD_FEATURE WHERE CODE = ?";
stmt = conn.prepareStatement(sql); stmt = conn.prepareStatement(sql);
stmt.setString(1, mblFeatureCode); stmt.setString(1, mblFeatureCode);
@ -144,7 +148,7 @@ public class AndroidFeatureDAOImpl implements MobileFeatureDAO {
"Error occurred while deleting android feature '" + "Error occurred while deleting android feature '" +
mblFeatureCode + "' from Android database.", e); mblFeatureCode + "' from Android database.", e);
} finally { } finally {
MobileDeviceManagementDAOUtil.cleanupResources(stmt, null); MobileDeviceManagementDAOUtil.cleanupResources(conn, stmt, null);
} }
return status; return status;
} }
@ -154,8 +158,9 @@ public class AndroidFeatureDAOImpl implements MobileFeatureDAO {
MobileDeviceManagementDAOException { MobileDeviceManagementDAOException {
PreparedStatement stmt = null; PreparedStatement stmt = null;
ResultSet rs = null; ResultSet rs = null;
Connection conn = null;
try { try {
Connection conn = this.getConnection(); conn = this.getConnection();
String sql = "SELECT ID, CODE, NAME, DESCRIPTION FROM AD_FEATURE WHERE ID = ?"; String sql = "SELECT ID, CODE, NAME, DESCRIPTION FROM AD_FEATURE WHERE ID = ?";
stmt = conn.prepareStatement(sql); stmt = conn.prepareStatement(sql);
stmt.setInt(1, mblFeatureId); stmt.setInt(1, mblFeatureId);
@ -178,7 +183,7 @@ public class AndroidFeatureDAOImpl implements MobileFeatureDAO {
"Error occurred while retrieving android feature '" + "Error occurred while retrieving android feature '" +
mblFeatureId + "' from the Android database.", e); mblFeatureId + "' from the Android database.", e);
} finally { } finally {
MobileDeviceManagementDAOUtil.cleanupResources(stmt, rs); MobileDeviceManagementDAOUtil.cleanupResources(conn, stmt, rs);
} }
} }
@ -187,8 +192,10 @@ public class AndroidFeatureDAOImpl implements MobileFeatureDAO {
MobileDeviceManagementDAOException { MobileDeviceManagementDAOException {
PreparedStatement stmt = null; PreparedStatement stmt = null;
ResultSet rs = null; ResultSet rs = null;
Connection conn = null;
try { try {
Connection conn = this.getConnection(); conn = this.getConnection();
String sql = "SELECT ID, CODE, NAME, DESCRIPTION FROM AD_FEATURE WHERE CODE = ?"; String sql = "SELECT ID, CODE, NAME, DESCRIPTION FROM AD_FEATURE WHERE CODE = ?";
stmt = conn.prepareStatement(sql); stmt = conn.prepareStatement(sql);
stmt.setString(1, mblFeatureCode); stmt.setString(1, mblFeatureCode);
@ -211,7 +218,7 @@ public class AndroidFeatureDAOImpl implements MobileFeatureDAO {
"Error occurred while retrieving android feature '" + "Error occurred while retrieving android feature '" +
mblFeatureCode + "' from the Android database.", e); mblFeatureCode + "' from the Android database.", e);
} finally { } finally {
MobileDeviceManagementDAOUtil.cleanupResources(stmt, rs); MobileDeviceManagementDAOUtil.cleanupResources(conn, stmt, rs);
} }
} }
@ -225,10 +232,11 @@ public class AndroidFeatureDAOImpl implements MobileFeatureDAO {
public List<MobileFeature> getAllFeatures() throws MobileDeviceManagementDAOException { public List<MobileFeature> getAllFeatures() throws MobileDeviceManagementDAOException {
PreparedStatement stmt = null; PreparedStatement stmt = null;
ResultSet rs = null; ResultSet rs = null;
Connection conn = null;
List<MobileFeature> features = new ArrayList<MobileFeature>(); List<MobileFeature> features = new ArrayList<MobileFeature>();
try { try {
Connection conn = this.getConnection(); conn = this.getConnection();
String sql = "SELECT ID, CODE, NAME, DESCRIPTION FROM AD_FEATURE"; String sql = "SELECT ID, CODE, NAME, DESCRIPTION FROM AD_FEATURE";
stmt = conn.prepareStatement(sql); stmt = conn.prepareStatement(sql);
rs = stmt.executeQuery(); rs = stmt.executeQuery();
@ -250,7 +258,7 @@ public class AndroidFeatureDAOImpl implements MobileFeatureDAO {
throw new AndroidFeatureManagementDAOException("Error occurred while retrieving all " + throw new AndroidFeatureManagementDAOException("Error occurred while retrieving all " +
"android features from the android database.", e); "android features from the android database.", e);
} finally { } finally {
MobileDeviceManagementDAOUtil.cleanupResources(stmt, rs); MobileDeviceManagementDAOUtil.cleanupResources(conn, stmt, rs);
} }
} }

Loading…
Cancel
Save