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;
Summary
Number of common nesting structure subtrees1
Number of refactorable cases0
Number of non-refactorable cases1
Time elapsed for finding largest common nesting structure subtrees (ms)0.4
Clones locationClones are in different classes
Number of node comparisons22
  1. {Non-refactorable}
    Mapping Summary
    Number of mapped statements8
    Number of unmapped statements in the first code fragment0
    Number of unmapped statements in the second code fragment0
    Time elapsed for statement mapping (ms)12.1
    Clone typeType 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
    3
    try
    Differences
    Expression1Expression2Difference
    SQLUtilities.closeResultSet(rs)SQLUtilities.closeResultSet(rs,true)ARGUMENT_NUMBER_MISMATCH
    Preondition Violations
    Expression SQLUtilities.closeResultSet(rs) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression SQLUtilities.closeResultSet(rs,true) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression SQLUtilities.closeResultSet(rs) is a void method call, and thus it cannot be parameterized
    Expression SQLUtilities.closeResultSet(rs,true) is a void method call, and thus it cannot be parameterized
    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
    if (rs.next())
    6
    if (rs.next())
    7
    result = rs.getInt(1);
    7
    result = rs.getInt(1);
    8
    return result;
    8
    return result;
    Precondition Violations (4)
    Row Violation
    1Expression SQLUtilities.closeResultSet(rs) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    2Expression SQLUtilities.closeResultSet(rs,true) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    3Expression SQLUtilities.closeResultSet(rs) is a void method call, and thus it cannot be parameterized
    4Expression SQLUtilities.closeResultSet(rs,true) is a void method call, and thus it cannot be parameterized