public class ViewSourceTab extends BaseSourceTab { /** SQL that retrieves the source of a stored procedure. */ private static String SQL = "select v.VIEWDEFINITION " + "from sys.SYSVIEWS v, sys.SYSTABLES t, sys.SYSSCHEMAS s " + "where v.TABLEID = t.TABLEID " + "and s.SCHEMAID = t.SCHEMAID " + "and t.TABLENAME = ? " + "and s.SCHEMANAME = ? "; /** Logger for this class. */ private final static ILogger s_log = LoggerController.createLogger(ViewSourceTab.class); public ViewSourceTab(String hint) { super(hint); } protected PreparedStatement createStatement() throws SQLException { final ISession session = getSession(); final IDatabaseObjectInfo doi = getDatabaseObjectInfo(); ISQLConnection conn = session.getSQLConnection(); if (s_log.isDebugEnabled()) { s_log.debug("Running View Source SQL: "+SQL); s_log.debug("View Name="+doi.getSimpleName()); s_log.debug("Schema Name="+doi.getSchemaName()); } PreparedStatement pstmt = conn.prepareStatement(SQL); pstmt.setString(1, doi.getSimpleName()); // view name pstmt.setString(2, doi.getSchemaName()); // schema name return pstmt;
public class MysqlProcedureSourceTab extends FormattedSourceTab { /** SQL that retrieves the source of a stored procedure. */ private static String SQL = "select routine_definition " + "from information_schema.ROUTINES " + "where ROUTINE_SCHEMA = ? " + "and ROUTINE_NAME = ? "; /** Logger for this class. */ private final static ILogger s_log = LoggerController.createLogger(MysqlProcedureSourceTab.class); public MysqlProcedureSourceTab(String hint) { super(hint); super.setCompressWhitespace(false); } protected PreparedStatement createStatement() throws SQLException { final ISession session = getSession(); final IDatabaseObjectInfo doi = getDatabaseObjectInfo(); if (s_log.isDebugEnabled()) { s_log.debug("Running SQL for procedure source: "+SQL); s_log.debug("schema="+doi.getCatalogName()); s_log.debug("procedure name="+doi.getSimpleName()); } ISQLConnection conn = session.getSQLConnection(); PreparedStatement pstmt = conn.prepareStatement(SQL); pstmt.setString(1, doi.getCatalogName()); pstmt.setString(2, doi.getSimpleName()); return pstmt;
Clone fragments detected by clone detection tool
File path: /sql12/plugins/derby/src/net/sourceforge/squirrel_sql/plugins/derby/tab/ViewSourceTab.java File path: /sql12/plugins/mysql/src/net/sourceforge/squirrel_sql/plugins/mysql/tab/MysqlProcedureSourceTab.java
Method name: Method name:
Number of AST nodes: 0 Number of AST nodes: 0
1
public class ViewSourceTab extends BaseSourceTab
1
public class MysqlProcedureSourceTab extends FormattedSourceTab
2
{
2
 {
3
	/** SQL that retrieves the source of a stored procedure. */
3
	/** SQL that retrieves the source of a stored procedure. */
4
	private static String SQL =
4
	private static String SQL =
5
        "select v.VIEWDEFINITION " +
5
        "select routine_definition " +
6
        "from sys.SYSVIEWS v, sys.SYSTABLES t, sys.SYSSCHEMAS s " +
6
        "from 
7
        "where v.TABLEID = t.TABLEID " +
8
        "and s.
7
information_schema.ROUTINES " +
9
SCHEMAID = t.SCHEMAID " +
8
        "where ROUTINE_SCHEMA = ? " +
10
        "and t.TABLENAME = ? " +
9
        "and 
11
        "and s.SCHEMANAME = ? ";
10
ROUTINE_NAME = ? ";
12
    
11
    
13
	/** Logger for this class. */
12
	/** Logger for this class. */
14
	private final static ILogger s_log =
13
	private final static ILogger s_log =
15
		LoggerController.createLogger(ViewSourceTab.class);
14
		LoggerController.createLogger(MysqlProcedureSourceTab.class);
16
	public ViewSourceTab(String hint)
15
	public MysqlProcedureSourceTab(String hint)
17
	{
16
	{
18
		super(hint);
17
		super(hint);
18
        super.setCompressWhitespace(false);
19
	}
19
	}
20
	protected PreparedStatement createStatement() throws SQLException
20
	protected PreparedStatement createStatement() throws SQLException
21
	{
21
	{
22
		final ISession session = getSession();
22
		final ISession session = getSession();
23
		final IDatabaseObjectInfo doi = getDatabaseObjectInfo();
23
		final IDatabaseObjectInfo doi = getDatabaseObjectInfo();
24
		ISQLConnection conn = session.getSQLConnection();
25
        if (s_log.isDebugEnabled()) {
24
        if (s_log.isDebugEnabled()) {
26
            s_log.debug("Running View Source SQL: "+SQL);
25
            s_log.debug("Running SQL for procedure source: "+SQL);
27
            s_log.debug("View Name="+doi.getSimpleName());
26
            s_log.debug("schema="+doi.getCatalogName());
28
            s_log.debug("Schema Name="+doi.getSchemaName());
27
            s_log.debug("procedure name="+doi.getSimpleName());
29
        }
28
        }
30
        
29
        
30
		ISQLConnection conn = session.getSQLConnection();
31
		PreparedStatement pstmt = conn.prepareStatement(SQL);
31
		PreparedStatement pstmt = conn.prepareStatement(SQL);
32
		pstmt.setString(1, doi.getSimpleName()); // view name
32
        pstmt.setString(1, doi.getCatalogName());
33
        
34
pstmt.setString(2, doi.getSchemaName()); // schema name
33
		pstmt.setString(2, doi.getSimpleName());
35
		return pstmt;
34
		return pstmt;
36
	
35
	
Summary
Number of common nesting structure subtrees0
Number of refactorable cases0
Number of non-refactorable cases0
Time elapsed for finding largest common nesting structure subtrees (ms)0.0
Clones location
Number of node comparisons0