db-derby-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Deepa Remesh (JIRA)" <derby-...@db.apache.org>
Subject [jira] Updated: (DERBY-447) getBoolean() throws data conversion exception for DECIMAL type in J2ME/CDC/Foundation
Date Fri, 08 Jul 2005 02:59:12 GMT
     [ http://issues.apache.org/jira/browse/DERBY-447?page=all ]

Deepa Remesh updated DERBY-447:
-------------------------------

    Attachment: derby-447.diff

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

> getBoolean() throws data conversion exception for DECIMAL type in J2ME/CDC/Foundation
> -------------------------------------------------------------------------------------
>
>          Key: DERBY-447
>          URL: http://issues.apache.org/jira/browse/DERBY-447
>      Project: Derby
>         Type: Bug
>   Components: JDBC
>     Reporter: Deepa Remesh
>     Assignee: Deepa Remesh
>  Attachments: derby-447.diff
>
> 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.

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
   http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see:
   http://www.atlassian.com/software/jira


Mime
View raw message