if (value == null || ((BlobDescriptor)value).getData() == null) { pstmt.setNull(position, _colDef.getSqlType()); } else { // for convenience cast the object to BlobDescriptor BlobDescriptor bdesc = (BlobDescriptor)value; // There are a couple of possible ways to update the data in the DB. // The first is to use setString like this: // bdesc.getBlob().setString(0, bdesc.getData()); // However, the DB2 driver throws an exception saying that that function // is not implemented, so we have to use the other method, which is to use a stream. pstmt.setBinaryStream(position, new ByteArrayInputStream(bdesc.getData()), bdesc.getData().length); }
if (value == null || ((DerbyClobDescriptor) value).getData() == null) { pstmt.setNull(position, _colDef.getSqlType()); } else { // for convenience cast the object to ClobDescriptor DerbyClobDescriptor cdesc = (DerbyClobDescriptor) value; pstmt.setCharacterStream(position, new StringReader(cdesc.getData()), cdesc.getData().length()); }
Clone fragments detected by clone detection tool
File path: /sql12/fw/src/net/sourceforge/squirrel_sql/fw/datasetviewer/cellcomponent/DataTypeBlob.java File path: /sql12/plugins/derby/src/net/sourceforge/squirrel_sql/plugins/derby/types/DerbyClobDataTypeComponent.java
Method name: void setPreparedStatementValue(PreparedStatement, Object, int) Method name: void setPreparedStatementValue(PreparedStatement, Object, int)
Number of AST nodes: 4 Number of AST nodes: 4
1
if (value == null || ((BlobDescriptor)value).getData() == null) {
1
if (value == null || ((DerbyClobDescriptor) value).getData() == null) {
2
			pstmt.setNull(position, _colDef.getSqlType());
2
         pstmt.setNull(position, _colDef.getSqlType());
3
		}
4
		else {
5
			
3
      } else {
6
// for convenience cast the object to BlobDescriptor
4
         // for convenience cast the object to ClobDescriptor
7
			BlobDescriptor bdesc = (BlobDescriptor)value;
5
         DerbyClobDescriptor cdesc = (DerbyClobDescriptor) value;
8
			// There are a couple of possible ways to update the data in the DB.
9
			// The first is to use setString like this:
10
			//		bdesc.getBlob().setString(0, bdesc.getData());
11
			// However, the DB2 driver throws an exception saying that that function
12
			// is not implemented, so we have to use the other method, which is to use a stream.		
13
			pstmt.setBinaryStream(position, new ByteArrayInputStream(bdesc.getData()), b
6
         pstmt.setCharacterStream(position,
7
                                  new StringReader(cdesc.getData()),
14
desc.getData().length);
8
                                  cdesc.getData().length());
15
		}
9
      }
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 having the same super class
Number of node comparisons16
  1. {Non-refactorable}
    Mapping Summary
    Number of mapped statements2
    Number of unmapped statements in the first code fragment2
    Number of unmapped statements in the second code fragment2
    Time elapsed for statement mapping (ms)10.6
    Clone typeType 2
    Mapped Statements
    ID Statement ID Statement
    1
    if (value == null || ((BlobDescriptor)value).getData() == null)
    1
    if (value == null || ((BlobDescriptor)value).getData() == null)
    1
    if (value == null || ((DerbyClobDescriptor)value).getData() == null)
    Differences
    Expression1Expression2Difference
    byte[]java.lang.StringVARIABLE_TYPE_MISMATCH
    net.sourceforge.squirrel_sql.fw.datasetviewer.cellcomponent.BlobDescriptornet.sourceforge.squirrel_sql.plugins.derby.types.DerbyClobDescriptorVARIABLE_TYPE_MISMATCH
    Preondition Violations
    Type byte[] of variable ((BlobDescriptor)value).getData() does not match with type java.lang.String of variable ((DerbyClobDescriptor)value).getData()
    • Make classes byte[] and java.lang.String extend a common superclass
    Type net.sourceforge.squirrel_sql.fw.datasetviewer.cellcomponent.BlobDescriptor does not match with type net.sourceforge.squirrel_sql.plugins.derby.types.DerbyClobDescriptor
    • Make classes net.sourceforge.squirrel_sql.fw.datasetviewer.cellcomponent.BlobDescriptor and net.sourceforge.squirrel_sql.plugins.derby.types.DerbyClobDescriptor extend a common superclass
    1
    if (value == null || ((DerbyClobDescriptor)value).getData() == null)
    2
    pstmt.setNull(position, _colDef.getSqlType());
    2
    pstmt.setNull(position, _colDef.getSqlType());
    else
            
                                                                                                                    
    3
    DerbyClobDescriptor cdesc = (DerbyClobDescriptor)value;
    Preondition Violations
    Unmatched statement DerbyClobDescriptor cdesc=(DerbyClobDescriptor)value; cannot be moved before the extracted code, because it has control dependencies from statements that will be extracted
    3
    DerbyClobDescriptor cdesc = (DerbyClobDescriptor)value;
    3
    BlobDescriptor bdesc = (BlobDescriptor)value;
    3
    BlobDescriptor bdesc = (BlobDescriptor)value;
    Preondition Violations
    Unmatched statement BlobDescriptor bdesc=(BlobDescriptor)value; cannot be moved before the extracted code, because it has control dependencies from statements that will be extracted
                                                                                                
                                                                                                                                                                                                      
    4
    pstmt.setCharacterStream(position, new StringReader(cdesc.getData()), cdesc.getData().length());
    Preondition Violations
    Unmatched statement pstmt.setCharacterStream(position,new StringReader(cdesc.getData()),cdesc.getData().length()); cannot be moved before or after the extracted code, because it throws exception(s) that should be caught by a try block that will be extracted
    4
    pstmt.setCharacterStream(position, new StringReader(cdesc.getData()), cdesc.getData().length());
    4
    pstmt.setBinaryStream(position, new ByteArrayInputStream(bdesc.getData()), bdesc.getData().length);
    4
    pstmt.setBinaryStream(position, new ByteArrayInputStream(bdesc.getData()), bdesc.getData().length);
    Preondition Violations
    Unmatched statement pstmt.setBinaryStream(position,new ByteArrayInputStream(bdesc.getData()),bdesc.getData().length); cannot be moved before or after the extracted code, because it throws exception(s) that should be caught by a try block that will be extracted
                                                                                                                                                                                                            
    Precondition Violations (6)
    Row Violation
    1Type byte[] of variable ((BlobDescriptor)value).getData() does not match with type java.lang.String of variable ((DerbyClobDescriptor)value).getData()
    2Type net.sourceforge.squirrel_sql.fw.datasetviewer.cellcomponent.BlobDescriptor does not match with type net.sourceforge.squirrel_sql.plugins.derby.types.DerbyClobDescriptor
    3Unmatched statement DerbyClobDescriptor cdesc=(DerbyClobDescriptor)value; cannot be moved before the extracted code, because it has control dependencies from statements that will be extracted
    4Unmatched statement BlobDescriptor bdesc=(BlobDescriptor)value; cannot be moved before the extracted code, because it has control dependencies from statements that will be extracted
    5Unmatched statement pstmt.setCharacterStream(position,new StringReader(cdesc.getData()),cdesc.getData().length()); cannot be moved before or after the extracted code, because it throws exception(s) that should be caught by a try block that will be extracted
    6Unmatched statement pstmt.setBinaryStream(position,new ByteArrayInputStream(bdesc.getData()),bdesc.getData().length); cannot be moved before or after the extracted code, because it throws exception(s) that should be caught by a try block that will be extracted