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 | } | |
See real code fragment | See real code fragment |
Number of common nesting structure subtrees | 1 |
Number of refactorable cases | 0 |
Number of non-refactorable cases | 1 |
Time elapsed for finding largest common nesting structure subtrees (ms) | 0.4 |
Clones location | Clones are in different classes having the same super class |
Number of node comparisons | 16 |
Number of mapped statements | 2 |
Number of unmapped statements in the first code fragment | 2 |
Number of unmapped statements in the second code fragment | 2 |
Time elapsed for statement mapping (ms) | 10.6 |
Clone type | Type 2 |
ID | Statement | ID | Statement | ||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
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()); | ||||||||||||||||
else | | ||||||||||||||||||
|
| 3 | DerbyClobDescriptor cdesc = (DerbyClobDescriptor)value; | ||||||||||||||||
3 | BlobDescriptor bdesc = (BlobDescriptor)value; |
| | ||||||||||||||||
|
| 4 | pstmt.setCharacterStream(position, new StringReader(cdesc.getData()), cdesc.getData().length()); | ||||||||||||||||
4 | pstmt.setBinaryStream(position, new ByteArrayInputStream(bdesc.getData()), bdesc.getData().length); |
| |
Row | Violation |
---|---|
1 | Type byte[] of variable ((BlobDescriptor)value).getData() does not match with type java.lang.String of variable ((DerbyClobDescriptor)value).getData() |
2 | Type net.sourceforge.squirrel_sql.fw.datasetviewer.cellcomponent.BlobDescriptor does not match with type net.sourceforge.squirrel_sql.plugins.derby.types.DerbyClobDescriptor |
3 | 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 | Unmatched statement BlobDescriptor bdesc=(BlobDescriptor)value; cannot be moved before the extracted code, because it has control dependencies from statements that will be extracted |
5 | 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 |
6 | 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 |