Issue Details (XML | Word | Printable)

Key: DERBY-518
Type: Bug Bug
Status: Closed Closed
Resolution: Fixed
Priority: Minor Minor
Assignee: Deepa Remesh
Reporter: Deepa Remesh
Votes: 0
Watchers: 0
Operations

If you were logged in you would be able to see more operations.
Derby

Data type mismatch error for boolean to DECIMAL conversion in J2ME

Created: 19/Aug/05 08:36 AM   Updated: 30/Sep/05 02:29 AM
Return to search
Component/s: JDBC
Affects Version/s: None
Fix Version/s: 10.1.2.1, 10.2.1.6

Time Tracking:
Not Specified

File Attachments:
  Size
File derby-518_2.diff 2005-08-27 02:59 AM Deepa Remesh 13 kB
File derby-518_2.status 2005-08-27 02:59 AM Deepa Remesh 0.5 kB
File Licensed for inclusion in ASF works derby-518_3.diff 2005-08-31 08:02 AM Deepa Remesh 13 kB
Environment: J2ME/CDC/Foundation Profile
Issue Links:
dependent
 

Resolution Date: 30/Sep/05 02:29 AM


 Description  « Hide
The test jdbcapi/resultset.java gives the following error when run in J2ME/CDC/FP :

Testing nullif(?,DECIMAL(10,5)) with setBoolean
ERROR XCL12: An attempt was made to put a data value of type 'boolean' into a data value of type 'DECIMAL'.

I found that setValue(boolean) is not implemented in BigIntegerDecimal, which is the class used for DECIMAL in J2ME. This is implemented in SQLDecimal and a similar implementation can be provided in BigIntegerDecimal.

On looking at the setValue methods in these classes, I also found that setValue(Object) is implemented in SQLDecimal but not in BigIntegerDecimal.


 All   Comments   Work Log   Change History   Subversion Commits      Sort Order: Ascending order - Click to sort in descending order
Deepa Remesh added a comment - 24/Aug/05 10:57 AM
This patch fixes DERBY-518 and DERBY-453 (Create a test wrapper to run tests using BigDecimal in J2ME/CDC/Foundation). The patch for DERBY-518 can be verified only with the patch for DERBY-453 and viceversa. So I am submitting it as one patch.

Kathey, I have addressed your comments for DERBY-453 in this patch.

Ran derbyall with Sun J2SE 1.4.2 and IBM's WCTME 5.7 J2ME/CDC/FP. 1 failure in J2ME, which is not related to this change.

Please review/commit this patch.

Kathey Marsden added a comment - 25/Aug/05 06:58 AM
Looking at SQLDecimal there are also setValue methods for the other primatives, such as setValue(float) and setValue(int).

Should these be added too?
If so I can go ahead and commit this patch and those can be added later, but I just want to clarify whether all these setValue methods should be there.


Deepa Remesh added a comment - 25/Aug/05 07:54 AM
Thanks Kathey for looking at the patch.

In case of BigIntergerDecimal, the setValue methods for other primitives are implemented in the parent class BinaryDecimal. As I understand, all valid conversions for DECIMAL type specified in the JDBC spec have to be covered.

Daniel John Debrunner added a comment - 25/Aug/05 09:32 AM
setValue(Object) should not be implemented in BigIntegerDecimal.

This is because there is no mapping from an Object type to a DECIMAL with JSR169.

Kathey Marsden added a comment - 25/Aug/05 10:33 AM
Oops, sorry I didn't look more closely.

Would it make sense for setValue(boolean) to live in BinaryDecimal as well and not be dependent on BigInteger like setValue(int) and the other setValue(primitive) methods?



Deepa Remesh added a comment - 26/Aug/05 03:17 AM
Thanks Kathey and Dan for your comments.

Kathey, I see the advantage in moving setValue(boolean) to BinaryDecimal and not making it depend on BigInteger - It can be used with all CDC implementations. I'll change this and submit a new patch.

Dan, I will remove setValue(Object) from my patch. I had opened this JIRA issue only for boolean type and I think I should not have overloaded this patch. However, one thing I am not clear about is the data type conversions in JSR169. Is there a table or some section in JSR169 for data type conversions? As it is a subset of JDBC3.0, I have been referring to JDBC3.0 spec and the subset API mentioned in JSR169. My understanding is that objects which are instances of Number or its subclass(other than BigDecimal) can be converted to DECIMAL type in JSR169. I will appreciate any pointers on this.

Daniel John Debrunner added a comment - 26/Aug/05 03:28 AM
Deepa, can you give a section number from JDBC 3.0 indicating any instance of Number can be converted to DECIMAL?

I know SQLDecimal has that code in there (conversion of Number) but I believe it is dead code and cannot/willnot be called.

Deepa Remesh added a comment - 26/Aug/05 05:06 AM
I am referring to "TABLE B-5 Conversions Performed by setObject Between Java Object Types and Target JDBC Types". I change my previous statement to instances of Double,Long, Float,Integer can be converted to DECIMAL. I was also basing on SQLDecimal methods and trying to match as closely as possible. As you mentioned, the code for conversion of Number looks like dead code.

Daniel John Debrunner added a comment - 26/Aug/05 05:12 AM
OK - I see B-5, but that is handled by the setObject() method of PreparedStatement. It does not get through to the setValue(Object) call of SQLDecimal or BigIntegerDecimal.


Deepa Remesh added a comment - 27/Aug/05 02:59 AM
I have deleted my old patch and uploaded the new patch for this. I have moved setValue(boolean) to BinaryDecimal and removed setValue(Object). This patch can be applied to 10.1 branch too.

Ran derbyall with Sun J2SE 1.4.2 and IBM's WCTME 5.7 J2ME/CDC/FP. 1 failure in J2ME, which is not related to this change. The testcase unit/T_RawStoreFactory.unit fails intermittently on J2ME. I will open a JIRA issue for this.

Deepa Remesh added a comment - 31/Aug/05 08:02 AM
I noticed that my patch became invalid because of a commit in between for DERBY-213.

I am submitting a new patch (derby-518_3.diff) with the same set of changes except for the following: The test resultset.java is still excluded from J2ME. It fails because of additions to the test which use a procedure that uses DriverManager. It would be good if this patch can be reviewed/committed. The problem with the test in J2ME can be tracked separately using DERBY-453.

Deepa Remesh added a comment - 31/Aug/05 02:24 PM
Since the comments for this patch are at different places, I am summarising the changes below:

1. Added setValue(boolean) to BinaryDecimal. This fixes DERBY-518.
2. Created a wrapper class BigDecimalHandler to be used in tests.
3. Test jdbcapi/resultset.java modified to call the wrapper methods in BigDecimalHandler
4. resultset.out master files modified
5. Comment in resultsetapp_properties modified. resultset test still fails in J2ME because of additions to the test. This will be tracked in DERBY-453.

Please review/commit this patch.

Kathey Marsden added a comment - 31/Aug/05 02:28 PM
Committed revision 264945 to the trunk.

Kathey Marsden added a comment - 31/Aug/05 02:32 PM
I changed a couple minor things when committing this patch with r264945

1) I updated the canon for the derbynet framework (JCC). Please check the diff.
2) I added the Apache license comment to BigDecimalHandler.

 

Kathey Marsden added a comment - 31/Aug/05 11:06 PM
second checkin for missed file.
Committed revision 265043.

Kathey Marsden added a comment - 31/Aug/05 11:09 PM
Part of the resolution for this issue was checked in with DERBY-518


Deepa Remesh added a comment - 01/Sep/05 03:24 AM
Thanks for looking into the patch. The update to the canon for derbynet is okay.

I will upload another patch for 10.1 branch.




Deepa Remesh added a comment - 16/Sep/05 08:01 AM
I merged the changes for DERBY-518 to 10.1 branch.

264945 : Initial check-in
265043: second check-in
279926: check-in to enable test resultset.java in J2ME

derbyall ran successfully with SUN jdk 1.4.2. The command I used for merge is:

svn merge -r 264944:264945 https://svn.apache.org/repos/asf/db/derby/code/trunk
svn merge -r 265042:265043 https://svn.apache.org/repos/asf/db/derby/code/trunk
svn merge -r 279925:279926 https://svn.apache.org/repos/asf/db/derby/code/trunk

Please update 10.1 branch with this patch.

Kathey Marsden added a comment - 17/Sep/05 07:29 AM
Submitted to the 10.1 branch.

Date: Fri Sep 16 15:25:39 2005
New Revision: 289667

URL: http://svn.apache.org/viewcvs?rev=289667&view=rev

Deepa Remesh added a comment - 17/Sep/05 07:54 AM
Fixed by revisions 264945, 265043, 279926 in trunk and revision 289667 in 10.1 branch

Deepa Remesh added a comment - 30/Sep/05 02:29 AM
reopening to fix fix version