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()); }
if (value == null || ((ClobDescriptor)value).getData() == null) { pstmt.setNull(position, _colDef.getSqlType()); } else { // for convenience cast the object to ClobDescriptor ClobDescriptor cdesc = (ClobDescriptor)value; // There are a couple of possible ways to update the data in the DB. // The first is to use setString like this: // cdesc.getClob().setString(0, cdesc.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.setCharacterStream(position, new StringReader(cdesc.getData()), cdesc.getData().length()); }
Clone fragments detected by clone detection tool
File path: /sql12/plugins/derby/src/net/sourceforge/squirrel_sql/plugins/derby/types/DerbyClobDataTypeComponent.java File path: /sql12/fw/src/net/sourceforge/squirrel_sql/fw/datasetviewer/cellcomponent/DataTypeClob.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 || ((DerbyClobDescriptor) value).getData() == null) {
1
if (value == null || ((ClobDescriptor)value).getData() == null) {
2
         pstmt.setNull(position, _colDef.getSqlType());
2
			pstmt.setNull(position, _colDef.getSqlType());
3
      } else {
4
         
3
		}
4
		else {
5
// for convenience cast the object to ClobDescriptor
5
			// for convenience cast the object to ClobDescriptor
6
         DerbyClobDescriptor cdesc = (DerbyClobDescriptor) value;
6
			ClobDescriptor cdesc = (ClobDescriptor)value;
7
         pstmt.setCharacterStream(position,
8
                                 
7
			// There are a couple of possible ways to update the data in the DB.
8
			// The first is to use setString like this:
9
			//		cdesc.getClob().setString(0, cdesc.getData());
10
			// However, the DB2 driver throws an exception saying that that function
11
			// is not implemented, so we have to use the other method, which is to use a stream.
9
 new StringReader(cdesc.getData()),
12
			pstmt.setCharacterStream(position, new StringReader(cdesc.getData()),
10
                                  cdesc.getData().length());
13
				cdesc.getData().length());
11
      }
14
		}
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 statements3
    Number of unmapped statements in the first code fragment1
    Number of unmapped statements in the second code fragment1
    Time elapsed for statement mapping (ms)10.3
    Clone typeType 2
    Mapped Statements
    ID Statement ID Statement
    1
    if (value == null || ((DerbyClobDescriptor)value).getData() == null)
    1
    if (value == null || ((DerbyClobDescriptor)value).getData() == null)
    1
    if (value == null || ((ClobDescriptor)value).getData() == null)
    Differences
    Expression1Expression2Difference
    net.sourceforge.squirrel_sql.plugins.derby.types.DerbyClobDescriptornet.sourceforge.squirrel_sql.fw.datasetviewer.cellcomponent.ClobDescriptorVARIABLE_TYPE_MISMATCH
    Preondition Violations
    Type net.sourceforge.squirrel_sql.plugins.derby.types.DerbyClobDescriptor does not match with type net.sourceforge.squirrel_sql.fw.datasetviewer.cellcomponent.ClobDescriptor
    • Make classes net.sourceforge.squirrel_sql.plugins.derby.types.DerbyClobDescriptor and net.sourceforge.squirrel_sql.fw.datasetviewer.cellcomponent.ClobDescriptor extend a common superclass
    1
    if (value == null || ((ClobDescriptor)value).getData() == null)
    2
    pstmt.setNull(position, _colDef.getSqlType());
    2
    pstmt.setNull(position, _colDef.getSqlType());
    else
    else
                                                                                                
    3
    ClobDescriptor cdesc = (ClobDescriptor)value;
    Preondition Violations
    Unmatched statement ClobDescriptor cdesc=(ClobDescriptor)value; cannot be moved before the extracted code, because it has control dependencies from statements that will be extracted
    3
    ClobDescriptor cdesc = (ClobDescriptor)value;
    3
    DerbyClobDescriptor cdesc = (DerbyClobDescriptor)value;
    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
                                                                                                                    
    4
    pstmt.setCharacterStream(position, new StringReader(cdesc.getData()), cdesc.getData().length());
    4
    pstmt.setCharacterStream(position, new StringReader(cdesc.getData()), cdesc.getData().length());
    4
    pstmt.setCharacterStream(position, new StringReader(cdesc.getData()), cdesc.getData().length());
    Differences
    Expression1Expression2Difference
    net.sourceforge.squirrel_sql.plugins.derby.types.DerbyClobDescriptornet.sourceforge.squirrel_sql.fw.datasetviewer.cellcomponent.ClobDescriptorVARIABLE_TYPE_MISMATCH
    net.sourceforge.squirrel_sql.plugins.derby.types.DerbyClobDescriptornet.sourceforge.squirrel_sql.fw.datasetviewer.cellcomponent.ClobDescriptorVARIABLE_TYPE_MISMATCH
    Preondition Violations
    Type net.sourceforge.squirrel_sql.plugins.derby.types.DerbyClobDescriptor of variable cdesc does not match with type net.sourceforge.squirrel_sql.fw.datasetviewer.cellcomponent.ClobDescriptor of variable cdesc
    • Make classes net.sourceforge.squirrel_sql.plugins.derby.types.DerbyClobDescriptor and net.sourceforge.squirrel_sql.fw.datasetviewer.cellcomponent.ClobDescriptor extend a common superclass
    Type net.sourceforge.squirrel_sql.plugins.derby.types.DerbyClobDescriptor of variable cdesc does not match with type net.sourceforge.squirrel_sql.fw.datasetviewer.cellcomponent.ClobDescriptor of variable cdesc
    • Make classes net.sourceforge.squirrel_sql.plugins.derby.types.DerbyClobDescriptor and net.sourceforge.squirrel_sql.fw.datasetviewer.cellcomponent.ClobDescriptor extend a common superclass
    4
    pstmt.setCharacterStream(position, new StringReader(cdesc.getData()), cdesc.getData().length());
    Precondition Violations (5)
    Row Violation
    1Type net.sourceforge.squirrel_sql.plugins.derby.types.DerbyClobDescriptor does not match with type net.sourceforge.squirrel_sql.fw.datasetviewer.cellcomponent.ClobDescriptor
    2Unmatched statement ClobDescriptor cdesc=(ClobDescriptor)value; cannot be moved before the extracted code, because it has control dependencies from statements that will be extracted
    3Unmatched statement DerbyClobDescriptor cdesc=(DerbyClobDescriptor)value; cannot be moved before the extracted code, because it has control dependencies from statements that will be extracted
    4Type net.sourceforge.squirrel_sql.plugins.derby.types.DerbyClobDescriptor of variable cdesc does not match with type net.sourceforge.squirrel_sql.fw.datasetviewer.cellcomponent.ClobDescriptor of variable cdesc
    5Type net.sourceforge.squirrel_sql.plugins.derby.types.DerbyClobDescriptor of variable cdesc does not match with type net.sourceforge.squirrel_sql.fw.datasetviewer.cellcomponent.ClobDescriptor of variable cdesc