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()); }
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/DataTypeClob.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 || ((ClobDescriptor)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 ClobDescriptor
4
         // for convenience cast the object to ClobDescriptor
7
			ClobDescriptor cdesc = (ClobDescriptor)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
			//		cdesc.getClob().setString(0, cdesc.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.setCharacterStream(position,
6
         pstmt.setCharacterStream(position,
14
 new StringReader(cdesc.getData()),
7
                                  new StringReader(cdesc.getData()),
15
				cdesc.getData().length());
8
                                  cdesc.getData().length());
16
		}
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.3
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.7
    Clone typeType 2
    Mapped Statements
    ID Statement ID Statement
    1
    if (value == null || ((ClobDescriptor)value).getData() == null)
    1
    if (value == null || ((ClobDescriptor)value).getData() == null)
    1
    if (value == null || ((DerbyClobDescriptor)value).getData() == null)
    Differences
    Expression1Expression2Difference
    net.sourceforge.squirrel_sql.fw.datasetviewer.cellcomponent.ClobDescriptornet.sourceforge.squirrel_sql.plugins.derby.types.DerbyClobDescriptorVARIABLE_TYPE_MISMATCH
    Preondition Violations
    Type net.sourceforge.squirrel_sql.fw.datasetviewer.cellcomponent.ClobDescriptor does not match with type net.sourceforge.squirrel_sql.plugins.derby.types.DerbyClobDescriptor
    • Make classes net.sourceforge.squirrel_sql.fw.datasetviewer.cellcomponent.ClobDescriptor 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
    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
    ClobDescriptor cdesc = (ClobDescriptor)value;
    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
                                                                                                
    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.fw.datasetviewer.cellcomponent.ClobDescriptornet.sourceforge.squirrel_sql.plugins.derby.types.DerbyClobDescriptorVARIABLE_TYPE_MISMATCH
    net.sourceforge.squirrel_sql.fw.datasetviewer.cellcomponent.ClobDescriptornet.sourceforge.squirrel_sql.plugins.derby.types.DerbyClobDescriptorVARIABLE_TYPE_MISMATCH
    Preondition Violations
    Type net.sourceforge.squirrel_sql.fw.datasetviewer.cellcomponent.ClobDescriptor of variable cdesc does not match with type net.sourceforge.squirrel_sql.plugins.derby.types.DerbyClobDescriptor of variable cdesc
    • Make classes net.sourceforge.squirrel_sql.fw.datasetviewer.cellcomponent.ClobDescriptor and net.sourceforge.squirrel_sql.plugins.derby.types.DerbyClobDescriptor extend a common superclass
    Type net.sourceforge.squirrel_sql.fw.datasetviewer.cellcomponent.ClobDescriptor of variable cdesc does not match with type net.sourceforge.squirrel_sql.plugins.derby.types.DerbyClobDescriptor of variable cdesc
    • Make classes net.sourceforge.squirrel_sql.fw.datasetviewer.cellcomponent.ClobDescriptor and net.sourceforge.squirrel_sql.plugins.derby.types.DerbyClobDescriptor 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.fw.datasetviewer.cellcomponent.ClobDescriptor does not match with type net.sourceforge.squirrel_sql.plugins.derby.types.DerbyClobDescriptor
    2Unmatched statement DerbyClobDescriptor cdesc=(DerbyClobDescriptor)value; cannot be moved before the extracted code, because it has control dependencies from statements that will be extracted
    3Unmatched statement ClobDescriptor cdesc=(ClobDescriptor)value; cannot be moved before the extracted code, because it has control dependencies from statements that will be extracted
    4Type net.sourceforge.squirrel_sql.fw.datasetviewer.cellcomponent.ClobDescriptor of variable cdesc does not match with type net.sourceforge.squirrel_sql.plugins.derby.types.DerbyClobDescriptor of variable cdesc
    5Type net.sourceforge.squirrel_sql.fw.datasetviewer.cellcomponent.ClobDescriptor of variable cdesc does not match with type net.sourceforge.squirrel_sql.plugins.derby.types.DerbyClobDescriptor of variable cdesc