File path: /sql12/fw/src/net/sourceforge/squirrel_sql/fw/datasetviewer/cellcomponent/DataTypeClob.java | File path: /sql12/fw/src/net/sourceforge/squirrel_sql/fw/datasetviewer/cellcomponent/DataTypeBlob.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 || ((BlobDescriptor)value).getData() == null) {↵ | |
2 | pstmt.setNull(position, _colDef.getSqlType());↵ | 2 | pstmt.setNull(position, _colDef.getSqlType());↵ | |
3 | }↵ | 3 | }↵ | |
4 | else {↵ | 4 | else {↵ | |
5 | // for convenience cast the object to ClobDescriptor↵ | 5 | // for convenience cast the object to BlobDescriptor↵ | |
6 | ClobDescriptor cdesc = (ClobDescriptor)value;↵ | 6 | BlobDescriptor bdesc = (BlobDescriptor)value;↵ | |
7 | // There are a couple of possible ways to update the data in the DB.↵ | 7 | // There are a couple of possible ways to update the data in the DB.↵ | |
8 | // The first is to use setString like this:↵ | 8 | // The first is to use setString like this:↵ | |
9 | // cdesc.getClob().setString(0, cdesc.getData());↵ | 9 | // bdesc.getBlob().setString(0, bdesc.getData());↵ | |
10 | // However, the DB2 driver throws an exception saying that that function↵ | 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.↵ | 11 | // is not implemented, so we have to use the other method, which is to use a stream. ↵ | |
12 | pstmt.setCharacterStream(position, new StringReader(cdesc.getData()),↵ | 12 | pstmt.setBinaryStream(position, new ByteArrayInputStream(bdesc.getData()),↵ | |
13 | cdesc.getData().length());↵ | 13 | bdesc.getData().length);↵ | |
14 | } | 14 |
| |
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.3 |
Clone type | Type 2 |
ID | Statement | ID | Statement | ||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
1 | if (value == null || ((ClobDescriptor)value).getData() == null) |
| 1 | if (value == null || ((BlobDescriptor)value).getData() == null) | |||||||||||||||
2 | pstmt.setNull(position, _colDef.getSqlType()); | 2 | pstmt.setNull(position, _colDef.getSqlType()); | ||||||||||||||||
else | | ||||||||||||||||||
|
| 3 | BlobDescriptor bdesc = (BlobDescriptor)value; | ||||||||||||||||
3 | ClobDescriptor cdesc = (ClobDescriptor)value; |
| | ||||||||||||||||
|
| 4 | pstmt.setBinaryStream(position, new ByteArrayInputStream(bdesc.getData()), bdesc.getData().length); | ||||||||||||||||
4 | pstmt.setCharacterStream(position, new StringReader(cdesc.getData()), cdesc.getData().length()); |
| |
Row | Violation |
---|---|
1 | Type java.lang.String of variable ((ClobDescriptor)value).getData() does not match with type byte[] of variable ((BlobDescriptor)value).getData() |
2 | Type net.sourceforge.squirrel_sql.fw.datasetviewer.cellcomponent.ClobDescriptor does not match with type net.sourceforge.squirrel_sql.fw.datasetviewer.cellcomponent.BlobDescriptor |
3 | 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 | Unmatched statement ClobDescriptor cdesc=(ClobDescriptor)value; cannot be moved before the extracted code, because it has control dependencies from statements that will be extracted |
5 | 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 |
6 | 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 |