if (isInputOK()) {
Statement stmt = null;
try {
String sql = "Create ROLE " + jtextfieldRolename.getText().trim();
stmt = session.getSQLConnection().createStatement();
stmt.execute(sql);
readRoles();
return true;
} catch (Exception e) {
JOptionPane.showMessageDialog(null, i18n.ERROR_SAVE_ROLE);
log.error(i18n.ERROR_SAVE_ROLE + CR + e.getLocalizedMessage());
} finally {
if (stmt != null) {
try {
stmt.close();
} catch (SQLException e) {
log.error(i18n.ERROR_GLOBAL_CLOSE_STATEMENT + CR + e.getLocalizedMessage());
}
}
}
}
Statement stmt = null;
try {
String sql = "Drop ROLE " + jtextfieldRolename.getText().trim();
stmt = session.getSQLConnection().createStatement();
stmt.execute(sql);
readRoles();
} catch (Exception e) {
JOptionPane.showMessageDialog(null, i18n.ERROR_DELETE_ROLE);
log.error(i18n.ERROR_DELETE_ROLE + CR + e.getLocalizedMessage());
} finally {
if (stmt != null) {
try {
stmt.close();
} catch (SQLException e) {
log.error(i18n.ERROR_GLOBAL_CLOSE_STATEMENT + CR + e.getLocalizedMessage());
}
}
}
Clone fragments detected by clone detection tool
File path: /sql12/plugins/firebirdmanager/src/net/sourceforge/squirrel_sql/plugins/firebirdmanager/gui/FirebirdManagerRoleFrame.java
|
|
File path: /sql12/plugins/firebirdmanager/src/net/sourceforge/squirrel_sql/plugins/firebirdmanager/gui/FirebirdManagerRoleFrame.java
|
Method name: boolean saveData()
|
|
Method name: void deleteRole()
|
Number of AST nodes: 8
|
|
Number of AST nodes: 6
|
|
1 | if (isInputOK()) {↵ | | |
|
2 | Statement stmt = null;↵ | | 1 | Statement stmt = null;↵
|
3 | try {↵ | | 2 | try {↵
|
4 | String sql = "Create ROLE " + jtextfieldRolename.getText().trim();↵ | | 3 | String sql = "Drop ROLE " + jtextfieldRolename.getText().trim();↵
|
5 | stmt = session.getSQLConnection().createStatement();↵ | | 4 | stmt = session.getSQLConnection().createStatement();↵
|
6 | stmt.execute(sql);↵ | | 5 | stmt.execute(sql);↵
|
7 | readRoles();↵ | | 6 | readRoles();↵
|
8 | return true;↵ | | 7 | ↵
|
9 | } catch (Exception e) {↵ | | 8 | } catch (Exception e) {↵
|
10 | JOptionPane.showMessageDialog(null, i18n.ERROR_SAVE_ROLE);↵ | | 9 | JOptionPane.showMessageDialog(null, i18n.ERROR_DELETE_ROLE);↵
|
11 | log.error(i18n.ERROR_SAVE_ROLE + CR + e.getLocalizedMessage());↵ | | 10 | log.error(i18n.ERROR_DELETE_ROLE + CR + e.getLocalizedMessage());↵
|
12 | } finally {↵ | | 11 | } finally {↵
|
13 | if (stmt != null) {↵ | | 12 | if (stmt != null) {↵
|
14 | try {↵ | | 13 | try {↵
|
15 | stmt.close();↵ | | 14 | stmt.close();↵
|
16 | } catch (SQLException e) {↵ | | 15 | } catch (SQLException e) {↵
|
17 | log.error(i18n.ERROR_GLOBAL_CLOSE_STATEMENT + CR + e.getLocalizedMessage());↵ | | 16 | log.error(i18n.ERROR_GLOBAL_CLOSE_STATEMENT + CR + e.getLocalizedMessage());↵
|
18 | }↵ | | 17 | }↵
|
19 | }↵ | | 18 | }↵
|
20 | }↵ | | 19 | }
|
21 | } | | | |
See real code fragment |
|
See real code fragment |
Summary
Number of common nesting structure subtrees | 1 |
Number of refactorable cases | 0 |
Number of non-refactorable cases | 1 |
Time elapsed for finding largest common nesting structure subtrees (ms) | 1.8 |
Clones location | Clones are declared in the same class |
Number of node comparisons | 32 |
-
{Non-refactorable}
Mapping Summary
Number of mapped statements | 6 |
Number of unmapped statements in the first code fragment | 1 |
Number of unmapped statements in the second code fragment | 0 |
Time elapsed for statement mapping (ms) | 4.4 |
Clone type | Type 3 |
Mapped Statements
ID |
Statement |
|
ID |
Statement |
2 | Statement stmt = null; | | 3 | Statement stmt = null; |
3 | try | | 4 | try |
4 | String sql = "Create ROLE " + jtextfieldRolename.getText().trim(); | | 5 | String sql = "Drop ROLE " + jtextfieldRolename.getText().trim(); |
5 | stmt = session.getSQLConnection().createStatement(); | | 6 | stmt = session.getSQLConnection().createStatement(); |
6 | | | 7 | |
7 | | | 8 | |
8 | | | | |
Precondition Violations (1)
Row |
Violation |
1 | Unmatched return true; |