int result = -1;
ResultSet rs = null;
try
{
String sql = "select count(*) from " + tableName;
rs = executeQuery(session, sql);
if (rs.next())
{
result = rs.getInt(1);
}
}
catch (Exception e)
{
/* Do Nothing - this can happen when the table doesn't exist */
}
finally
{
SQLUtilities.closeResultSet(rs);
}
return result;
int result = -1;
ResultSet rs = null;
try
{
String sql = "select count(*) from " + tableName;
rs = executeQuery(session, sql);
if (rs.next())
{
result = rs.getInt(1);
}
} catch (Exception e)
{
/* Do Nothing - this can happen when the table doesn't exist */
} finally
{
SQLUtilities.closeResultSet(rs, true);
}
return result;
Clone fragments detected by clone detection tool
File path: /sql12/plugins/dbdiff/src/net/sourceforge/squirrel_sql/plugins/dbdiff/util/DBUtil.java
|
|
File path: /sql12/plugins/dbcopy/src/net/sourceforge/squirrel_sql/plugins/dbcopy/util/DBUtil.java
|
Method name: int getTableCount(ISession, String)
|
|
Method name: int getTableCount(ISession, String)
|
Number of AST nodes: 8
|
|
Number of AST nodes: 8
|
|
1 | int result = -1;↵ | | 1 | int result = -1;↵
|
2 | ResultSet rs = null;↵ | | 2 | ResultSet rs = null;↵
|
3 | try↵ | | 3 | try↵
|
4 | {↵ | | 4 | {↵
|
5 | String sql = "select count(*) from " + tableName;↵ | | 5 | String sql = "select count(*) from " + tableName;↵
|
6 | rs = executeQuery(session, sql);↵ | | 6 | rs = executeQuery(session, sql);↵
|
7 | if (rs.next())↵ | | 7 | if (rs.next())↵
|
8 | {↵ | | 8 | {↵
|
9 | result = rs.getInt(1);↵ | | 9 | result = rs.getInt(1);↵
|
10 | }↵ | | 10 | }↵
|
11 | }↵ | | 11 | }↵
|
12 | catch (Exception e)↵ | | 12 | catch (Exception e)↵
|
13 | {↵ | | 13 | {↵
|
14 | /* Do Nothing - this can happen when the table doesn't exist */↵ | | 14 | /* Do Nothing - this can happen when the table doesn't exist */↵
|
15 | }↵ | | 15 | }↵
|
16 | finally↵ | | 16 | finally↵
|
17 | {↵ | | 17 | {↵
|
18 | SQLUtilities.closeResultSet(rs);↵ | | 18 | SQLUtilities.closeResultSet(rs, true);↵
|
19 | }↵ | | 19 | }↵
|
20 | return result; | | 20 | return result;
|
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) | 0.4 |
Clones location | Clones are in different classes |
Number of node comparisons | 22 |
-
{Non-refactorable}
Mapping Summary
Number of mapped statements | 8 |
Number of unmapped statements in the first code fragment | 0 |
Number of unmapped statements in the second code fragment | 0 |
Time elapsed for statement mapping (ms) | 12.1 |
Clone type | Type 2 |
Mapped Statements
ID |
Statement |
|
ID |
Statement |
1 | int result = -1; | | 1 | int result = -1; |
2 | ResultSet rs = null; | | 2 | ResultSet rs = null; |
3 | try | | 3 | try |
4 | String sql = "select count(*) from " + tableName; | | 4 | String sql = "select count(*) from " + tableName; |
5 | rs = executeQuery(session, sql); | | 5 | rs = executeQuery(session, sql); |
6 | | | 6 | |
7 | | | 7 | |
8 | return result; | | 8 | return result; |
Precondition Violations (4)
Row |
Violation |
1 | Expression SQLUtilities.closeResultSet(rs) cannot be parameterized, because it has dependencies to/from statements that will be extracted |
2 | Expression SQLUtilities.closeResultSet(rs,true) cannot be parameterized, because it has dependencies to/from statements that will be extracted |
3 | Expression SQLUtilities.closeResultSet(rs) is a void method call, and thus it cannot be parameterized |
4 | Expression SQLUtilities.closeResultSet(rs,true) is a void method call, and thus it cannot be parameterized |