[jira] Commented: (DERBY-680) In ij, executing a prepared statement with numeric/decimal parameter fails with NullPointerException in J2ME/CDC/FP

2006-02-01 Thread Daniel John Debrunner (JIRA)
[ 
http://issues.apache.org/jira/browse/DERBY-680?page=comments#action_12364854 ] 

Daniel John Debrunner commented on DERBY-680:
-

Submitted changes to ejbql test from patch derby-680_v2.diff , as they are 
separate from the code change to ij.

> In ij, executing a prepared statement with numeric/decimal parameter fails 
> with NullPointerException in J2ME/CDC/FP
> ---
>
>  Key: DERBY-680
>  URL: http://issues.apache.org/jira/browse/DERBY-680
>  Project: Derby
> Type: Bug
>   Components: Tools
> Versions: 10.2.0.0
>  Environment: j9_foundation VM in IBM WCTME 5.7
> Reporter: Deepa Remesh
> Assignee: Deepa Remesh
>  Attachments: derby-680_v2.diff, derby-680_v2.status
>
> NPE is thrown in ij when executing prepared statement which 
> - has numeric/decimal parameters
> - does not return any result set
> Repro for this problem is the test lang/cast.sql. This test currently fails 
> in CDC/FP.
> The following lines in the test throw NPE:
> execute q10 using 'values 123456.78';
> execute q11 using 'values 123456.78';
> where q10 is "prepare q10 as 'insert into t1 (num) values cast(? as 
> numeric(18))';"
> and q11 is "prepare q11 as 'insert into t1 (dc) values cast(? as 
> decimal(18))';"
> The stack trace for failure is:
> java.lang.NullPointerException
> at org.apache.derby.impl.tools.ij.util.DisplayMulti(util.java:666)
> at 
> org.apache.derby.impl.tools.ij.utilMain.displayResult(utilMain.java:398)
> at org.apache.derby.impl.tools.ij.utilMain.go(utilMain.java:290)
> at org.apache.derby.impl.tools.ij.Main.go(Main.java:203)
> at org.apache.derby.impl.tools.ij.Main.mainCore(Main.java:169)
> at org.apache.derby.impl.tools.ij.Main.main(Main.java:75)
> at org.apache.derby.tools.ij.main(ij.java:56)
> This happens in the following code. Since the above prepared statements do 
> not return result sets, call to getMetaData() will return null. But in the 
> code, no check is done to see if getMetaData() returns null before calling 
> getColumnType.
> ---
>   // In J2ME there is no object 
> that represents
>   // a DECIMAL value. By default 
> use String to
>   // pass values around, but for 
> integral types
>   // first convert to a integral 
> type from the DECIMAL
>   // because strings like 3.4 are 
> not convertible to
>   // an integral type.
>   switch 
> (ps.getMetaData().getColumnType(c))
>   {
>   case Types.BIGINT:
>   ps.setLong(c, 
> rs.getLong(c));
>   break;
>   case Types.INTEGER:
>   case Types.SMALLINT:
>   case Types.TINYINT:
>   ps.setInt(c, 
> rs.getInt(c));
>   break;
>   default:
>   
> ps.setString(c,rs.getString(c));
>   break;
>   }   
> ---

-- 
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



[jira] Commented: (DERBY-680) In ij, executing a prepared statement with numeric/decimal parameter fails with NullPointerException in J2ME/CDC/FP

2006-01-25 Thread Kathey Marsden (JIRA)
[ 
http://issues.apache.org/jira/browse/DERBY-680?page=comments#action_12364002 ] 

Kathey Marsden commented on DERBY-680:
--

I think we should have a regression test that verifies the fix submitted with 
the fix, , either by enabling cast.sql with J2ME  or adding the case to another 
test that already runs with J2ME


> In ij, executing a prepared statement with numeric/decimal parameter fails 
> with NullPointerException in J2ME/CDC/FP
> ---
>
>  Key: DERBY-680
>  URL: http://issues.apache.org/jira/browse/DERBY-680
>  Project: Derby
> Type: Bug
>   Components: Tools
> Versions: 10.2.0.0
>  Environment: j9_foundation VM in IBM WCTME 5.7
> Reporter: Deepa Remesh
> Assignee: Deepa Remesh
>  Attachments: derby-680_v2.diff, derby-680_v2.status
>
> NPE is thrown in ij when executing prepared statement which 
> - has numeric/decimal parameters
> - does not return any result set
> Repro for this problem is the test lang/cast.sql. This test currently fails 
> in CDC/FP.
> The following lines in the test throw NPE:
> execute q10 using 'values 123456.78';
> execute q11 using 'values 123456.78';
> where q10 is "prepare q10 as 'insert into t1 (num) values cast(? as 
> numeric(18))';"
> and q11 is "prepare q11 as 'insert into t1 (dc) values cast(? as 
> decimal(18))';"
> The stack trace for failure is:
> java.lang.NullPointerException
> at org.apache.derby.impl.tools.ij.util.DisplayMulti(util.java:666)
> at 
> org.apache.derby.impl.tools.ij.utilMain.displayResult(utilMain.java:398)
> at org.apache.derby.impl.tools.ij.utilMain.go(utilMain.java:290)
> at org.apache.derby.impl.tools.ij.Main.go(Main.java:203)
> at org.apache.derby.impl.tools.ij.Main.mainCore(Main.java:169)
> at org.apache.derby.impl.tools.ij.Main.main(Main.java:75)
> at org.apache.derby.tools.ij.main(ij.java:56)
> This happens in the following code. Since the above prepared statements do 
> not return result sets, call to getMetaData() will return null. But in the 
> code, no check is done to see if getMetaData() returns null before calling 
> getColumnType.
> ---
>   // In J2ME there is no object 
> that represents
>   // a DECIMAL value. By default 
> use String to
>   // pass values around, but for 
> integral types
>   // first convert to a integral 
> type from the DECIMAL
>   // because strings like 3.4 are 
> not convertible to
>   // an integral type.
>   switch 
> (ps.getMetaData().getColumnType(c))
>   {
>   case Types.BIGINT:
>   ps.setLong(c, 
> rs.getLong(c));
>   break;
>   case Types.INTEGER:
>   case Types.SMALLINT:
>   case Types.TINYINT:
>   ps.setInt(c, 
> rs.getInt(c));
>   break;
>   default:
>   
> ps.setString(c,rs.getString(c));
>   break;
>   }   
> ---

-- 
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



[jira] Commented: (DERBY-680) In ij, executing a prepared statement with numeric/decimal parameter fails with NullPointerException in J2ME/CDC/FP

2006-01-23 Thread Deepa Remesh (JIRA)
[ 
http://issues.apache.org/jira/browse/DERBY-680?page=comments#action_12363686 ] 

Deepa Remesh commented on DERBY-680:


lang/ejbql.sql tests 'abs' and 'absval' functions. So removing the prepared 
statements from lang/ejbql.sql does not remove any testing. Dan mentioned this 
in an earlier comment. 

The test that was giving NPE was lang/cast.sql. With the patch, I have run the 
test in J2ME and verified that the NPE does not occur. However, this test is 
still disabled in J2ME because some recent additions to the test require 
BigDecimal class. Because of these additional tests, it fails towards the end 
but the failure is not related to this issue. 

> In ij, executing a prepared statement with numeric/decimal parameter fails 
> with NullPointerException in J2ME/CDC/FP
> ---
>
>  Key: DERBY-680
>  URL: http://issues.apache.org/jira/browse/DERBY-680
>  Project: Derby
> Type: Bug
>   Components: Tools
> Versions: 10.2.0.0
>  Environment: j9_foundation VM in IBM WCTME 5.7
> Reporter: Deepa Remesh
> Assignee: Deepa Remesh
>  Attachments: derby-680_v2.diff, derby-680_v2.status
>
> NPE is thrown in ij when executing prepared statement which 
> - has numeric/decimal parameters
> - does not return any result set
> Repro for this problem is the test lang/cast.sql. This test currently fails 
> in CDC/FP.
> The following lines in the test throw NPE:
> execute q10 using 'values 123456.78';
> execute q11 using 'values 123456.78';
> where q10 is "prepare q10 as 'insert into t1 (num) values cast(? as 
> numeric(18))';"
> and q11 is "prepare q11 as 'insert into t1 (dc) values cast(? as 
> decimal(18))';"
> The stack trace for failure is:
> java.lang.NullPointerException
> at org.apache.derby.impl.tools.ij.util.DisplayMulti(util.java:666)
> at 
> org.apache.derby.impl.tools.ij.utilMain.displayResult(utilMain.java:398)
> at org.apache.derby.impl.tools.ij.utilMain.go(utilMain.java:290)
> at org.apache.derby.impl.tools.ij.Main.go(Main.java:203)
> at org.apache.derby.impl.tools.ij.Main.mainCore(Main.java:169)
> at org.apache.derby.impl.tools.ij.Main.main(Main.java:75)
> at org.apache.derby.tools.ij.main(ij.java:56)
> This happens in the following code. Since the above prepared statements do 
> not return result sets, call to getMetaData() will return null. But in the 
> code, no check is done to see if getMetaData() returns null before calling 
> getColumnType.
> ---
>   // In J2ME there is no object 
> that represents
>   // a DECIMAL value. By default 
> use String to
>   // pass values around, but for 
> integral types
>   // first convert to a integral 
> type from the DECIMAL
>   // because strings like 3.4 are 
> not convertible to
>   // an integral type.
>   switch 
> (ps.getMetaData().getColumnType(c))
>   {
>   case Types.BIGINT:
>   ps.setLong(c, 
> rs.getLong(c));
>   break;
>   case Types.INTEGER:
>   case Types.SMALLINT:
>   case Types.TINYINT:
>   ps.setInt(c, 
> rs.getInt(c));
>   break;
>   default:
>   
> ps.setString(c,rs.getString(c));
>   break;
>   }   
> ---

-- 
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



[jira] Commented: (DERBY-680) In ij, executing a prepared statement with numeric/decimal parameter fails with NullPointerException in J2ME/CDC/FP

2006-01-20 Thread Kathey Marsden (JIRA)
[ 
http://issues.apache.org/jira/browse/DERBY-680?page=comments#action_12363504 ] 

Kathey Marsden commented on DERBY-680:
--

Since the prepared statements have been taken out of lang/ejbql.sql, I wonder 
if we are still testing the case that was giving the NPE ( ij, executing a 
prepared statement with numeric/decimal parameters).Is that covered in 
another test?


> In ij, executing a prepared statement with numeric/decimal parameter fails 
> with NullPointerException in J2ME/CDC/FP
> ---
>
>  Key: DERBY-680
>  URL: http://issues.apache.org/jira/browse/DERBY-680
>  Project: Derby
> Type: Bug
>   Components: Tools
> Versions: 10.2.0.0
>  Environment: j9_foundation VM in IBM WCTME 5.7
> Reporter: Deepa Remesh
> Assignee: Deepa Remesh
>  Attachments: derby-680_v2.diff, derby-680_v2.status
>
> NPE is thrown in ij when executing prepared statement which 
> - has numeric/decimal parameters
> - does not return any result set
> Repro for this problem is the test lang/cast.sql. This test currently fails 
> in CDC/FP.
> The following lines in the test throw NPE:
> execute q10 using 'values 123456.78';
> execute q11 using 'values 123456.78';
> where q10 is "prepare q10 as 'insert into t1 (num) values cast(? as 
> numeric(18))';"
> and q11 is "prepare q11 as 'insert into t1 (dc) values cast(? as 
> decimal(18))';"
> The stack trace for failure is:
> java.lang.NullPointerException
> at org.apache.derby.impl.tools.ij.util.DisplayMulti(util.java:666)
> at 
> org.apache.derby.impl.tools.ij.utilMain.displayResult(utilMain.java:398)
> at org.apache.derby.impl.tools.ij.utilMain.go(utilMain.java:290)
> at org.apache.derby.impl.tools.ij.Main.go(Main.java:203)
> at org.apache.derby.impl.tools.ij.Main.mainCore(Main.java:169)
> at org.apache.derby.impl.tools.ij.Main.main(Main.java:75)
> at org.apache.derby.tools.ij.main(ij.java:56)
> This happens in the following code. Since the above prepared statements do 
> not return result sets, call to getMetaData() will return null. But in the 
> code, no check is done to see if getMetaData() returns null before calling 
> getColumnType.
> ---
>   // In J2ME there is no object 
> that represents
>   // a DECIMAL value. By default 
> use String to
>   // pass values around, but for 
> integral types
>   // first convert to a integral 
> type from the DECIMAL
>   // because strings like 3.4 are 
> not convertible to
>   // an integral type.
>   switch 
> (ps.getMetaData().getColumnType(c))
>   {
>   case Types.BIGINT:
>   ps.setLong(c, 
> rs.getLong(c));
>   break;
>   case Types.INTEGER:
>   case Types.SMALLINT:
>   case Types.TINYINT:
>   ps.setInt(c, 
> rs.getInt(c));
>   break;
>   default:
>   
> ps.setString(c,rs.getString(c));
>   break;
>   }   
> ---

-- 
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



[jira] Commented: (DERBY-680) In ij, executing a prepared statement with numeric/decimal parameter fails with NullPointerException in J2ME/CDC/FP

2006-01-09 Thread Daniel John Debrunner (JIRA)
[ 
http://issues.apache.org/jira/browse/DERBY-680?page=comments#action_12362228 ] 

Daniel John Debrunner commented on DERBY-680:
-

I think it's ok to change these SQL statements to not use prepared statements 
and ij's using clause.
The return value of the fn abs is what is being tested here, not the fact that 
if you pass 4.4 into a prepared statement  and compare it to 4 you get false.

> In ij, executing a prepared statement with numeric/decimal parameter fails 
> with NullPointerException in J2ME/CDC/FP
> ---
>
>  Key: DERBY-680
>  URL: http://issues.apache.org/jira/browse/DERBY-680
>  Project: Derby
> Type: Bug
>   Components: Tools
> Versions: 10.2.0.0
>  Environment: j9_foundation VM in IBM WCTME 5.7
> Reporter: Deepa Remesh
> Assignee: Deepa Remesh
>  Attachments: derby-680.diff, derby-680.status
>
> NPE is thrown in ij when executing prepared statement which 
> - has numeric/decimal parameters
> - does not return any result set
> Repro for this problem is the test lang/cast.sql. This test currently fails 
> in CDC/FP.
> The following lines in the test throw NPE:
> execute q10 using 'values 123456.78';
> execute q11 using 'values 123456.78';
> where q10 is "prepare q10 as 'insert into t1 (num) values cast(? as 
> numeric(18))';"
> and q11 is "prepare q11 as 'insert into t1 (dc) values cast(? as 
> decimal(18))';"
> The stack trace for failure is:
> java.lang.NullPointerException
> at org.apache.derby.impl.tools.ij.util.DisplayMulti(util.java:666)
> at 
> org.apache.derby.impl.tools.ij.utilMain.displayResult(utilMain.java:398)
> at org.apache.derby.impl.tools.ij.utilMain.go(utilMain.java:290)
> at org.apache.derby.impl.tools.ij.Main.go(Main.java:203)
> at org.apache.derby.impl.tools.ij.Main.mainCore(Main.java:169)
> at org.apache.derby.impl.tools.ij.Main.main(Main.java:75)
> at org.apache.derby.tools.ij.main(ij.java:56)
> This happens in the following code. Since the above prepared statements do 
> not return result sets, call to getMetaData() will return null. But in the 
> code, no check is done to see if getMetaData() returns null before calling 
> getColumnType.
> ---
>   // In J2ME there is no object 
> that represents
>   // a DECIMAL value. By default 
> use String to
>   // pass values around, but for 
> integral types
>   // first convert to a integral 
> type from the DECIMAL
>   // because strings like 3.4 are 
> not convertible to
>   // an integral type.
>   switch 
> (ps.getMetaData().getColumnType(c))
>   {
>   case Types.BIGINT:
>   ps.setLong(c, 
> rs.getLong(c));
>   break;
>   case Types.INTEGER:
>   case Types.SMALLINT:
>   case Types.TINYINT:
>   ps.setInt(c, 
> rs.getInt(c));
>   break;
>   default:
>   
> ps.setString(c,rs.getString(c));
>   break;
>   }   
> ---

-- 
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



[jira] Commented: (DERBY-680) In ij, executing a prepared statement with numeric/decimal parameter fails with NullPointerException in J2ME/CDC/FP

2006-01-05 Thread Deepa Remesh (JIRA)
[ 
http://issues.apache.org/jira/browse/DERBY-680?page=comments#action_12361879 ] 

Deepa Remesh commented on DERBY-680:


Thanks Dan for looking at this patch. lang/ejbql.sql tests abs and absval 
functions. I think using cast may not be okay.  These are the execute 
statements which fail in J2ME (leaving out statements which pass):

create table myint( a int );
insert into myint values (null);
autocommit off;

-- Prepare Statements, should pass and return 1
prepare p1 as 'select abs(?) from myint';
prepare p1 as 'select 1 from myint where ? <= 4';
execute p1 using 'values absval( 4.4 )';
execute p1 using 'values absval( -4.4 )';

-- Prepare Statements, should pass and return 1
prepare p2 as 'select {fn abs(?)} from myint';
prepare p2 as 'select 1 from myint where ? <= 4';
execute p2 using 'values {fn abs( 4.4 )}';
execute p2 using 'values {fn abs( -4.4 )}';
execute p2 using 'values {fn abs( -4.444 )}';

Please look at these statements and let me know if you think it is okay to 
change them . 

> In ij, executing a prepared statement with numeric/decimal parameter fails 
> with NullPointerException in J2ME/CDC/FP
> ---
>
>  Key: DERBY-680
>  URL: http://issues.apache.org/jira/browse/DERBY-680
>  Project: Derby
> Type: Bug
>   Components: Tools
> Versions: 10.2.0.0
>  Environment: j9_foundation VM in IBM WCTME 5.7
> Reporter: Deepa Remesh
> Assignee: Deepa Remesh
>  Attachments: derby-680.diff, derby-680.status
>
> NPE is thrown in ij when executing prepared statement which 
> - has numeric/decimal parameters
> - does not return any result set
> Repro for this problem is the test lang/cast.sql. This test currently fails 
> in CDC/FP.
> The following lines in the test throw NPE:
> execute q10 using 'values 123456.78';
> execute q11 using 'values 123456.78';
> where q10 is "prepare q10 as 'insert into t1 (num) values cast(? as 
> numeric(18))';"
> and q11 is "prepare q11 as 'insert into t1 (dc) values cast(? as 
> decimal(18))';"
> The stack trace for failure is:
> java.lang.NullPointerException
> at org.apache.derby.impl.tools.ij.util.DisplayMulti(util.java:666)
> at 
> org.apache.derby.impl.tools.ij.utilMain.displayResult(utilMain.java:398)
> at org.apache.derby.impl.tools.ij.utilMain.go(utilMain.java:290)
> at org.apache.derby.impl.tools.ij.Main.go(Main.java:203)
> at org.apache.derby.impl.tools.ij.Main.mainCore(Main.java:169)
> at org.apache.derby.impl.tools.ij.Main.main(Main.java:75)
> at org.apache.derby.tools.ij.main(ij.java:56)
> This happens in the following code. Since the above prepared statements do 
> not return result sets, call to getMetaData() will return null. But in the 
> code, no check is done to see if getMetaData() returns null before calling 
> getColumnType.
> ---
>   // In J2ME there is no object 
> that represents
>   // a DECIMAL value. By default 
> use String to
>   // pass values around, but for 
> integral types
>   // first convert to a integral 
> type from the DECIMAL
>   // because strings like 3.4 are 
> not convertible to
>   // an integral type.
>   switch 
> (ps.getMetaData().getColumnType(c))
>   {
>   case Types.BIGINT:
>   ps.setLong(c, 
> rs.getLong(c));
>   break;
>   case Types.INTEGER:
>   case Types.SMALLINT:
>   case Types.TINYINT:
>   ps.setInt(c, 
> rs.getInt(c));
>   break;
>   default:
>   
> ps.setString(c,rs.getString(c));
>   break;
>   }   
> ---

-- 
This message is automatically gen

[jira] Commented: (DERBY-680) In ij, executing a prepared statement with numeric/decimal parameter fails with NullPointerException in J2ME/CDC/FP

2006-01-05 Thread Daniel John Debrunner (JIRA)
[ 
http://issues.apache.org/jira/browse/DERBY-680?page=comments#action_12361874 ] 

Daniel John Debrunner commented on DERBY-680:
-

I think the code is correct but I wonder if the ejbql test should be modified 
so that a CDC/Foundation specific master file is not required?
Would the purpose of the test be changed by adding a cast to the expression 
that causes the failure in J2ME?

> In ij, executing a prepared statement with numeric/decimal parameter fails 
> with NullPointerException in J2ME/CDC/FP
> ---
>
>  Key: DERBY-680
>  URL: http://issues.apache.org/jira/browse/DERBY-680
>  Project: Derby
> Type: Bug
>   Components: Tools
> Versions: 10.2.0.0
>  Environment: j9_foundation VM in IBM WCTME 5.7
> Reporter: Deepa Remesh
> Assignee: Deepa Remesh
>  Attachments: derby-680.diff, derby-680.status
>
> NPE is thrown in ij when executing prepared statement which 
> - has numeric/decimal parameters
> - does not return any result set
> Repro for this problem is the test lang/cast.sql. This test currently fails 
> in CDC/FP.
> The following lines in the test throw NPE:
> execute q10 using 'values 123456.78';
> execute q11 using 'values 123456.78';
> where q10 is "prepare q10 as 'insert into t1 (num) values cast(? as 
> numeric(18))';"
> and q11 is "prepare q11 as 'insert into t1 (dc) values cast(? as 
> decimal(18))';"
> The stack trace for failure is:
> java.lang.NullPointerException
> at org.apache.derby.impl.tools.ij.util.DisplayMulti(util.java:666)
> at 
> org.apache.derby.impl.tools.ij.utilMain.displayResult(utilMain.java:398)
> at org.apache.derby.impl.tools.ij.utilMain.go(utilMain.java:290)
> at org.apache.derby.impl.tools.ij.Main.go(Main.java:203)
> at org.apache.derby.impl.tools.ij.Main.mainCore(Main.java:169)
> at org.apache.derby.impl.tools.ij.Main.main(Main.java:75)
> at org.apache.derby.tools.ij.main(ij.java:56)
> This happens in the following code. Since the above prepared statements do 
> not return result sets, call to getMetaData() will return null. But in the 
> code, no check is done to see if getMetaData() returns null before calling 
> getColumnType.
> ---
>   // In J2ME there is no object 
> that represents
>   // a DECIMAL value. By default 
> use String to
>   // pass values around, but for 
> integral types
>   // first convert to a integral 
> type from the DECIMAL
>   // because strings like 3.4 are 
> not convertible to
>   // an integral type.
>   switch 
> (ps.getMetaData().getColumnType(c))
>   {
>   case Types.BIGINT:
>   ps.setLong(c, 
> rs.getLong(c));
>   break;
>   case Types.INTEGER:
>   case Types.SMALLINT:
>   case Types.TINYINT:
>   ps.setInt(c, 
> rs.getInt(c));
>   break;
>   default:
>   
> ps.setString(c,rs.getString(c));
>   break;
>   }   
> ---

-- 
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



[jira] Commented: (DERBY-680) In ij, executing a prepared statement with numeric/decimal parameter fails with NullPointerException in J2ME/CDC/FP

2005-12-27 Thread Daniel John Debrunner (JIRA)
[ 
http://issues.apache.org/jira/browse/DERBY-680?page=comments#action_12361280 ] 

Daniel John Debrunner commented on DERBY-680:
-

I'm looking at reviewing & committing this patch.

> In ij, executing a prepared statement with numeric/decimal parameter fails 
> with NullPointerException in J2ME/CDC/FP
> ---
>
>  Key: DERBY-680
>  URL: http://issues.apache.org/jira/browse/DERBY-680
>  Project: Derby
> Type: Bug
>   Components: Tools
> Versions: 10.2.0.0
>  Environment: j9_foundation VM in IBM WCTME 5.7
> Reporter: Deepa Remesh
> Assignee: Deepa Remesh
>  Attachments: derby-680.diff, derby-680.status
>
> NPE is thrown in ij when executing prepared statement which 
> - has numeric/decimal parameters
> - does not return any result set
> Repro for this problem is the test lang/cast.sql. This test currently fails 
> in CDC/FP.
> The following lines in the test throw NPE:
> execute q10 using 'values 123456.78';
> execute q11 using 'values 123456.78';
> where q10 is "prepare q10 as 'insert into t1 (num) values cast(? as 
> numeric(18))';"
> and q11 is "prepare q11 as 'insert into t1 (dc) values cast(? as 
> decimal(18))';"
> The stack trace for failure is:
> java.lang.NullPointerException
> at org.apache.derby.impl.tools.ij.util.DisplayMulti(util.java:666)
> at 
> org.apache.derby.impl.tools.ij.utilMain.displayResult(utilMain.java:398)
> at org.apache.derby.impl.tools.ij.utilMain.go(utilMain.java:290)
> at org.apache.derby.impl.tools.ij.Main.go(Main.java:203)
> at org.apache.derby.impl.tools.ij.Main.mainCore(Main.java:169)
> at org.apache.derby.impl.tools.ij.Main.main(Main.java:75)
> at org.apache.derby.tools.ij.main(ij.java:56)
> This happens in the following code. Since the above prepared statements do 
> not return result sets, call to getMetaData() will return null. But in the 
> code, no check is done to see if getMetaData() returns null before calling 
> getColumnType.
> ---
>   // In J2ME there is no object 
> that represents
>   // a DECIMAL value. By default 
> use String to
>   // pass values around, but for 
> integral types
>   // first convert to a integral 
> type from the DECIMAL
>   // because strings like 3.4 are 
> not convertible to
>   // an integral type.
>   switch 
> (ps.getMetaData().getColumnType(c))
>   {
>   case Types.BIGINT:
>   ps.setLong(c, 
> rs.getLong(c));
>   break;
>   case Types.INTEGER:
>   case Types.SMALLINT:
>   case Types.TINYINT:
>   ps.setInt(c, 
> rs.getInt(c));
>   break;
>   default:
>   
> ps.setString(c,rs.getString(c));
>   break;
>   }   
> ---

-- 
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



[jira] Commented: (DERBY-680) In ij, executing a prepared statement with numeric/decimal parameter fails with NullPointerException in J2ME/CDC/FP

2005-11-14 Thread Deepa Remesh (JIRA)
[ 
http://issues.apache.org/jira/browse/DERBY-680?page=comments#action_12357621 ] 

Deepa Remesh commented on DERBY-680:


By changing the above code to check for the value returned by ps.getMetaData() 
, the prepared statements q10 and q11 listed in the description above work. The 
test lang/cast.sql also passes with JSR169.
---
// In J2ME there is no object 
that represents
// a DECIMAL value. By default 
use String to
// pass values around, but for 
integral types
// first convert to a integral 
type from the DECIMAL
// because strings like 3.4 are 
not convertible to
// an integral type.
ResultSetMetaData  psmd = 
ps.getMetaData();
if(psmd != null) {
switch 
(psmd.getColumnType(c))
{
case Types.BIGINT:
ps.setLong(c, 
rs.getLong(c));
break;
case Types.INTEGER:
case Types.SMALLINT:
case Types.TINYINT:
ps.setInt(c, 
rs.getInt(c));
break;
default:

ps.setString(c,rs.getString(c));
break;
}
}
else {

ps.setString(c,rs.getString(c));
}
---

But the following case does not work because there is no way to get parameter 
metadata in JSR169 since ParameterMetaData is not available. So, there is no 
equivalent to "switch (ps.getMetaData().getColumnType(c))" to determine the the 
column/parameter type and call the corresponding setXXX method.

---
ij> create table int_tab (i int);
ij> prepare i1  as 'insert into int_tab values (?)';
ij> execute i1 using 'values 3.4';
IJ WARNING: Autocommit may close using result set
ERROR 22018: Invalid character string format for type INTEGER.
ERROR 22018: Invalid character string format for type INTEGER.
at org.apache.derby.iapi.error.StandardException.newException(StandardEx
ception.java:311)
at org.apache.derby.iapi.types.DataType.invalidFormat(DataType.java:1049
)
at org.apache.derby.iapi.types.SQLInteger.setValue(SQLInteger.java:340)
at org.apache.derby.impl.jdbc.EmbedPreparedStatement.setString(EmbedPrep
aredStatement.java:452)
at org.apache.derby.impl.tools.ij.util.DisplayMulti(util.java:684)
at org.apache.derby.impl.tools.ij.utilMain.displayResult(utilMain.java:3
98)
at org.apache.derby.impl.tools.ij.utilMain.go(utilMain.java:290)
at org.apache.derby.impl.tools.ij.Main.go(Main.java:203)
at org.apache.derby.impl.tools.ij.Main.mainCore(Main.java:169)
at org.apache.derby.impl.tools.ij.Main.main(Main.java:75)
at org.apache.derby.tools.ij.main(ij.java:56)
---

I would like to know if anyone has suggestions to handle this. Thanks.


> In ij, executing a prepared statement with numeric/decimal parameter fails 
> with NullPointerException in J2ME/CDC/FP
> ---
>
>  Key: DERBY-680
>