Issue Details (XML | Word | Printable)

Key: DERBY-447
Type: Bug Bug
Status: Closed Closed
Resolution: Fixed
Priority: Major Major
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

getBoolean() throws data conversion exception for DECIMAL type in J2ME/CDC/Foundation

Created: 08/Jul/05 06:32 AM   Updated: 30/Sep/05 02:18 AM
Return to search
Component/s: JDBC
Affects Version/s: 10.1.1.0, 10.2.1.6
Fix Version/s: 10.1.2.1, 10.2.1.6

Time Tracking:
Not Specified

File Attachments:
  Size
File Licensed for inclusion in ASF works derby-447_2.diff 2005-07-09 12:41 AM Deepa Remesh 0.7 kB

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


 Description  « Hide
The call to the ResultSet method getBoolean() for a DECIMAL value throws data conversion exception with J2ME/CDC/Foundation. The class BigIntegerDecimal, which is used for DECIMAL support in J2ME/CDC/Foundation, does not override the getBoolean() method from the class DataType. The getBoolean() method in DataType simply throws a data conversion exception.

 All   Comments   Work Log   Change History   Subversion Commits      Sort Order: Ascending order - Click to sort in descending order
Deepa Remesh added a comment - 08/Jul/05 11:56 AM
This patch implements getBoolean() method in BigIntegerDecimal, which is the class used for DECIMAL support in J2ME/CDC/Foundation. The method returns false for zero or null values and true for all other values.

Here is the method implementation:
// 0 or null is false, all else is true
public boolean getBoolean()
{
String bigDecimalString = getString();
if(bigDecimalString == null)
return false;

BigInteger bi = new BigInteger(data2c);
return bi.compareTo(java.math.BigInteger.ZERO) != 0;
}

I ran the test jdbcapi/resultset.java using IBM WCTME5.7 Foundation profile. Before the change the output file resultset.out had the following output for calls to getBoolean() for DECIMAL values:

getBoolean(10) got exception
Data Conversion SQLException
getBoolean(dc) got exception
Data Conversion SQLException

After the change, getBoolean() for DECIMAL value does not throw data conversion exception. The output file now has:

getBoolean(10): true
getBoolean(dc): true

To verify that the getBoolean() method returns the right value, I also tested using the following DECIMAL values (-10.1, 0, -0, 0.00, -0.00, null).

Note: The test jdbcapi/resultset.java is currently excluded for J2ME/Foundation. The following line "runwithfoundation=false" in resultset_app.properties has to be commented to be able to run the test. Also, the test will not be successful because of other BigDecimal methods. So the specific lines in output has to be checked in resultset.out. I am working on a test wrapper to make the test work in J2ME/Foundation and will submit this in a separate task.

Please review this patch and commit it.

Thanks,
Deepa

Deepa Remesh made changes - 08/Jul/05 11:56 AM
Field Original Value New Value
Attachment derby-447.diff [ 12311136 ]
Daniel John Debrunner added a comment - 08/Jul/05 02:15 PM
Rather than this code

 String bigDecimalString = getString();
if(bigDecimalString == null)
return false;

to see if the value is NULL, you should use the isNull() method. e.g.

if (isNull())
   return false;

otherwise it looks good. Can you re-submit a patch?

Repository Revision Date User Message
ASF #209845 Fri Jul 08 17:28:52 UTC 2005 djd DERBY-447
This patch implements getBoolean() method in BigIntegerDecimal, which is the class used for DECIMAL support
in J2ME/CDC/Foundation. The method returns false for zero or null values and true for all other values.

Contributed by Deepa Remesh dremesh@gmail.com
Files Changed
MODIFY /incubator/derby/code/trunk/java/engine/org/apache/derby/iapi/types/BigIntegerDecimal.java

Deepa Remesh added a comment - 09/Jul/05 12:41 AM
Hi Dan,

Thanks for pointing this out. I was using a round-about way to check if the value is null. Please look at the re-submitted patch.

Deepa

Deepa Remesh made changes - 09/Jul/05 12:41 AM
Attachment derby-447_2.diff [ 12311145 ]
Daniel John Debrunner made changes - 09/Jul/05 02:20 AM
Affects Version/s 10.2.0.0 [ 11187 ]
Affects Version/s 10.1.1.0 [ 10993 ]
Daniel John Debrunner added a comment - 09/Jul/05 02:29 AM
Committed revision 209845.

Daniel John Debrunner made changes - 09/Jul/05 02:29 AM
Fix Version/s 10.2.0.0 [ 11187 ]
Deepa Remesh made changes - 12/Jul/05 07:52 AM
Resolution Fixed [ 1 ]
Status Open [ 1 ] Resolved [ 5 ]
Deepa Remesh made changes - 12/Jul/05 07:52 AM
Status Resolved [ 5 ] Closed [ 6 ]
Repository Revision Date User Message
ASF #219260 Fri Jul 15 23:26:12 UTC 2005 djd DERBY-447 - merge 209845 from trunk. Fix getBoolean() on DECIMAL in JSR169.
Files Changed
MODIFY /incubator/derby/code/branches/10.1/java/engine/org/apache/derby/iapi/types/BigIntegerDecimal.java

Daniel John Debrunner added a comment - 16/Jul/05 08:27 AM
Committed revision 219260 on 10.1 branch (merge of 209845)
svn merge -r 209844:209845 https://svn.apache.org/repos/asf/incubator/derby/code/trunk/

Daniel John Debrunner made changes - 21/Jul/05 04:29 PM
Resolution Fixed [ 1 ]
Status Closed [ 6 ] Reopened [ 4 ]
Daniel John Debrunner added a comment - 21/Jul/05 04:30 PM
Also marked fixed in 10.1 branch

Daniel John Debrunner made changes - 21/Jul/05 04:30 PM
Fix Version/s 10.1.1.0 [ 10993 ]
Daniel John Debrunner made changes - 21/Jul/05 04:30 PM
Resolution Fixed [ 1 ]
Status Reopened [ 4 ] Closed [ 6 ]
Kathey Marsden added a comment - 16/Sep/05 01:55 AM
reopening to fix fix in

Kathey Marsden made changes - 16/Sep/05 01:55 AM
Status Closed [ 6 ] Reopened [ 4 ]
Resolution Fixed [ 1 ]
Kathey Marsden made changes - 16/Sep/05 01:55 AM
Resolution Fixed [ 1 ]
Fix Version/s 10.1.1.0 [ 10993 ]
Status Reopened [ 4 ] Resolved [ 5 ]
Fix Version/s 10.1.2.0 [ 12310270 ]
Kathey Marsden made changes - 16/Sep/05 01:55 AM
Status Resolved [ 5 ] Closed [ 6 ]
Deepa Remesh added a comment - 30/Sep/05 02:15 AM
reopening to fix fix version

Deepa Remesh made changes - 30/Sep/05 02:15 AM
Status Closed [ 6 ] Reopened [ 4 ]
Resolution Fixed [ 1 ]
Deepa Remesh made changes - 30/Sep/05 02:15 AM
Fix Version/s 10.1.1.1 [ 12310332 ]
Deepa Remesh made changes - 30/Sep/05 02:18 AM
Status Reopened [ 4 ] Closed [ 6 ]
Resolution Fixed [ 1 ]
Repository Revision Date User Message
ASF #392304 Fri Apr 07 14:32:48 UTC 2006 bpendleton DERBY-1184: registerOutParameter(int,int,String) should throw exception

Patch contributed by Kristian Waagan (Kristian.Waagan@Sun.com)

The method 'CallableStatement.registerOutParameter(int,int,String)'
does nothing in the client driver. As stated in DERBY-447, the method throws
a not-implemented exception in the embedded driver. The method should be
changed to do this on the client side as well.
Files Changed
MODIFY /db/derby/code/trunk/java/client/org/apache/derby/client/am/CallableStatement.java
MODIFY /db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/derbynet/callable.java