InputStream is = rs.getBinaryStream(index); if (rs.wasNull()) { ps.setNull(index, type); return; } // Open file output stream long millis = System.currentTimeMillis(); File f = File.createTempFile("blob", "" + millis); f.deleteOnExit(); FileOutputStream fos = new FileOutputStream(f); if (log.isDebugEnabled()) { // i18n[DBUtil.info.bindblobfile=bindBlobVarInFile: Opening temp file '{0}'] String msg = s_stringMgr.getString("DBUtil.info.bindblobfile", f.getAbsolutePath()); log.debug(msg); } // read rs input stream write to file output stream byte[] buf = new byte[_prefs.getFileCacheBufferSize()]; int length = 0; int total = 0; while ((length = is.read(buf)) >= 0) { if (log.isDebugEnabled()) { // i18n[DBUtil.info.bindbloblength=bindBlobVarInFile: writing '{0}' bytes.] String msg = s_stringMgr.getString("DBUtil.info.bindbloblength", Integer.valueOf(length)); log.debug(msg); } fos.write(buf, 0, length); total += length; } fos.close(); // set the ps to read from the file we just created. FileInputStream fis = new FileInputStream(f); BufferedInputStream bis = new BufferedInputStream(fis); ps.setBinaryStream(index, bis, total);
InputStream is = rs.getAsciiStream(index); if (rs.wasNull()) { ps.setNull(index, type); return; } // Open file output stream long millis = System.currentTimeMillis(); File f = File.createTempFile("clob", "" + millis); f.deleteOnExit(); FileOutputStream fos = new FileOutputStream(f); if (log.isDebugEnabled()) { // i18n[DBUtil.info.bindclobfile=bindClobVarInFile: Opening temp file '{0}'] String msg = s_stringMgr.getString("DBUtil.info.bindclobfile", f.getAbsolutePath()); log.debug(msg); } // read rs input stream write to file output stream byte[] buf = new byte[_prefs.getFileCacheBufferSize()]; int length = 0; int total = 0; while ((length = is.read(buf)) >= 0) { if (log.isDebugEnabled()) { // i18n[DBUtil.info.bindcloblength=bindClobVarInFile: writing '{0}' bytes.] String msg = s_stringMgr.getString("DBUtil.info.bindcloblength", Integer.valueOf(length)); log.debug(msg); } fos.write(buf, 0, length); total += length; } fos.close(); // set the ps to read from the file we just created. FileInputStream fis = new FileInputStream(f); BufferedInputStream bis = new BufferedInputStream(fis); ps.setAsciiStream(index, bis, total);
Clone fragments detected by clone detection tool
File path: /sql12/plugins/dbcopy/src/net/sourceforge/squirrel_sql/plugins/dbcopy/util/DBUtil.java File path: /sql12/plugins/dbcopy/src/net/sourceforge/squirrel_sql/plugins/dbcopy/util/DBUtil.java
Method name: void bindBlobVarInFile(PreparedStatement, int, ResultSet, int) Method name: void bindClobVarInFile(PreparedStatement, int, ResultSet, int)
Number of AST nodes: 24 Number of AST nodes: 24
1
InputStream is = rs.getBinaryStream(index);
1
InputStream is = rs.getAsciiStream(index);
2
		if (rs.wasNull())
2
		if (rs.wasNull())
3
		{
3
		{
4
			ps.setNull(index, type);
4
			ps.setNull(index, type);
5
			return;
5
			return;
6
		}
6
		}
7
		// Open file output stream
7
		// Open file output stream
8
		long millis = System.currentTimeMillis();
8
		long millis = System.currentTimeMillis();
9
		File f = File.createTempFile("blob", "" + millis);
9
		File f = File.createTempFile("clob", "" + millis);
10
		f.deleteOnExit();
10
		f.deleteOnExit();
11
		FileOutputStream fos = new FileOutputStream(f);
11
		FileOutputStream fos = new FileOutputStream(f);
12
		if (log.isDebugEnabled())
12
		if (log.isDebugEnabled())
13
		{
13
		{
14
			// i18n[DBUtil.info.bindblobfile=bindBlobVarInFile: Opening temp file '{0}']
14
			// i18n[DBUtil.info.bindclobfile=bindClobVarInFile: Opening temp file '{0}']
15
			String msg = s_stringMgr.getString("DBUtil.info.bindblobfile", f.getAbsolutePath());
15
			String msg = s_stringMgr.getString("DBUtil.info.bindclobfile", f.getAbsolutePath());
16
			log.debug(msg);
16
			log.debug(msg);
17
		}
17
		}
18
		// read rs input stream write to file output stream
18
		// read rs input stream write to file output stream
19
		byte[] buf = new byte[_prefs.getFileCacheBufferSize()];
19
		byte[] buf = new byte[_prefs.getFileCacheBufferSize()];
20
		int length = 0;
20
		int length = 0;
21
		int total = 0;
21
		int total = 0;
22
		while ((length = is.read(buf)) >= 0)
22
		while ((length = is.read(buf)) >= 0)
23
		{
23
		{
24
			if (log.isDebugEnabled())
24
			if (log.isDebugEnabled())
25
			{
25
			{
26
				// i18n[DBUtil.info.bindbloblength=bindBlobVarInFile: writing '{0}' bytes.]
26
				// i18n[DBUtil.info.bindcloblength=bindClobVarInFile: writing '{0}' bytes.]
27
				String msg = s_stringMgr.getString("DBUtil.info.bindbloblength", Integer.valueOf(length));
27
				String msg = s_stringMgr.getString("DBUtil.info.bindcloblength", Integer.valueOf(length));
28
				log.debug(msg);
28
				log.debug(msg);
29
			}
29
			}
30
			fos.write(buf, 0, length);
30
			fos.write(buf, 0, length);
31
			total += length;
31
			total += length;
32
		}
32
		}
33
		fos.close();
33
		fos.close();
34
		// set the ps to read from the file we just created.
34
		// set the ps to read from the file we just created.
35
		FileInputStream fis = new FileInputStream(f);
35
		FileInputStream fis = new FileInputStream(f);
36
		BufferedInputStream bis = new BufferedInputStream(fis);
36
		BufferedInputStream bis = new BufferedInputStream(fis);
37
		ps.setBinaryStream(index, bis, total);
37
		ps.setAsciiStream(index, bis, total);
Summary
Number of common nesting structure subtrees1
Number of refactorable cases1
Number of non-refactorable cases0
Time elapsed for finding largest common nesting structure subtrees (ms)0.8
Clones locationClones are declared in the same class
Number of node comparisons124
  1. {Refactorable}
    Mapping Summary
    Number of mapped statements24
    Number of unmapped statements in the first code fragment0
    Number of unmapped statements in the second code fragment0
    Time elapsed for statement mapping (ms)13.5
    Clone typeType 2
    Mapped Statements
    ID Statement ID Statement
    1
    InputStream is = rs.getBinaryStream(index);
    1
    InputStream is = rs.getBinaryStream(index);
    1
    InputStream is = rs.getAsciiStream(index);
    Differences
    Expression1Expression2Difference
    getBinaryStreamgetAsciiStreamMETHOD_INVOCATION_NAME_MISMATCH
    1
    InputStream is = rs.getAsciiStream(index);
    2
    if (rs.wasNull())
    2
    if (rs.wasNull())
    3
    ps.setNull(index, type);
    3
    ps.setNull(index, type);
    4
    return;
    4
    return;
    5
    long millis = System.currentTimeMillis();
    5
    long millis = System.currentTimeMillis();
    6
    File f = File.createTempFile("blob", "" + millis);
    6
    File f = File.createTempFile("blob", "" + millis);
    6
    File f = File.createTempFile("clob", "" + millis);
    Differences
    Expression1Expression2Difference
    "blob""clob"LITERAL_VALUE_MISMATCH
    6
    File f = File.createTempFile("clob", "" + millis);
    7
    f.deleteOnExit();
    7
    f.deleteOnExit();
    8
    FileOutputStream fos = new FileOutputStream(f);
    8
    FileOutputStream fos = new FileOutputStream(f);
    9
    if (log.isDebugEnabled())
    9
    if (log.isDebugEnabled())
    10
    String msg = s_stringMgr.getString("DBUtil.info.bindblobfile", f.getAbsolutePath());
    10
    String msg = s_stringMgr.getString("DBUtil.info.bindblobfile", f.getAbsolutePath());
    10
    String msg = s_stringMgr.getString("DBUtil.info.bindclobfile", f.getAbsolutePath());
    Differences
    Expression1Expression2Difference
    "DBUtil.info.bindblobfile""DBUtil.info.bindclobfile"LITERAL_VALUE_MISMATCH
    10
    String msg = s_stringMgr.getString("DBUtil.info.bindclobfile", f.getAbsolutePath());
    11
    log.debug(msg);
    11
    log.debug(msg);
    12
    byte[] buf = new byte[_prefs.getFileCacheBufferSize()];
    12
    byte[] buf = new byte[_prefs.getFileCacheBufferSize()];
    13
    int length = 0;
    13
    int length = 0;
    14
    int total = 0;
    14
    int total = 0;
    15
    while ((length = is.read(buf)) >= 0)
    15
    while ((length = is.read(buf)) >= 0)
    16
    if (log.isDebugEnabled())
    16
    if (log.isDebugEnabled())
    17
    String msg = s_stringMgr.getString("DBUtil.info.bindbloblength", Integer.valueOf(length));
    17
    String msg = s_stringMgr.getString("DBUtil.info.bindbloblength", Integer.valueOf(length));
    17
    String msg = s_stringMgr.getString("DBUtil.info.bindcloblength", Integer.valueOf(length));
    Differences
    Expression1Expression2Difference
    "DBUtil.info.bindbloblength""DBUtil.info.bindcloblength"LITERAL_VALUE_MISMATCH
    17
    String msg = s_stringMgr.getString("DBUtil.info.bindcloblength", Integer.valueOf(length));
    18
    log.debug(msg);
    18
    log.debug(msg);
    19
    fos.write(buf, 0, length);
    19
    fos.write(buf, 0, length);
    20
    total += length;
    20
    total += length;
    21
    fos.close();
    21
    fos.close();
    22
    FileInputStream fis = new FileInputStream(f);
    22
    FileInputStream fis = new FileInputStream(f);
    23
    BufferedInputStream bis = new BufferedInputStream(fis);
    23
    BufferedInputStream bis = new BufferedInputStream(fis);
    24
    ps.setBinaryStream(index, bis, total);
    24
    ps.setBinaryStream(index, bis, total);
    24
    ps.setAsciiStream(index, bis, total);
    Differences
    Expression1Expression2Difference
    setBinaryStreamsetAsciiStreamMETHOD_INVOCATION_NAME_MISMATCH
    Preondition Violations
    Expression ps.setBinaryStream(index,bis,total) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression ps.setAsciiStream(index,bis,total) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression ps.setBinaryStream(index,bis,total) is a void method call, and thus it cannot be parameterized
    Expression ps.setAsciiStream(index,bis,total) is a void method call, and thus it cannot be parameterized
    24
    ps.setAsciiStream(index, bis, total);
    Precondition Violations (4)
    Row Violation
    1Expression ps.setBinaryStream(index,bis,total) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    2Expression ps.setAsciiStream(index,bis,total) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    3Expression ps.setBinaryStream(index,bis,total) is a void method call, and thus it cannot be parameterized
    4Expression ps.setAsciiStream(index,bis,total) is a void method call, and thus it cannot be parameterized