You are viewing a plain text version of this content. The canonical link for it is here.
Posted to derby-dev@db.apache.org by "Deepa Remesh (JIRA)" <de...@db.apache.org> on 2005/11/03 19:04:47 UTC

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

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
 Assigned to: Deepa Remesh 


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] Closed: (DERBY-680) In ij, executing a prepared statement with numeric/decimal parameter fails with NullPointerException in J2ME/CDC/FP

Posted by "Dyre Tjeldvoll (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/DERBY-680?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Dyre Tjeldvoll closed DERBY-680.
--------------------------------


> In ij, executing a prepared statement with numeric/decimal parameter fails with NullPointerException in J2ME/CDC/FP
> -------------------------------------------------------------------------------------------------------------------
>
>                 Key: DERBY-680
>                 URL: https://issues.apache.org/jira/browse/DERBY-680
>             Project: Derby
>          Issue Type: Bug
>          Components: Tools
>    Affects Versions: 10.2.1.6
>         Environment: j9_foundation VM in IBM WCTME 5.7
>            Reporter: Deepa Remesh
>            Assignee: Deepa Remesh
>             Fix For: 10.3.1.4
>
>         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.
-
You can reply to this email to add a comment to the issue online.


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

Posted by "Daniel John Debrunner (JIRA)" <de...@db.apache.org>.
    [ 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] Updated: (DERBY-680) In ij, executing a prepared statement with numeric/decimal parameter fails with NullPointerException in J2ME/CDC/FP

Posted by "Deepa Remesh (JIRA)" <de...@db.apache.org>.
     [ http://issues.apache.org/jira/browse/DERBY-680?page=all ]

Deepa Remesh updated DERBY-680:
-------------------------------

    Attachment:     (was: derby-680_v2.diff)

> 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

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

Posted by "Daniel John Debrunner (JIRA)" <de...@db.apache.org>.
    [ 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

Posted by "Kathey Marsden (JIRA)" <de...@db.apache.org>.
    [ 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] Updated: (DERBY-680) In ij, executing a prepared statement with numeric/decimal parameter fails with NullPointerException in J2ME/CDC/FP

Posted by "Deepa Remesh (JIRA)" <de...@db.apache.org>.
     [ http://issues.apache.org/jira/browse/DERBY-680?page=all ]

Deepa Remesh updated DERBY-680:
-------------------------------

    Attachment:     (was: derby-680.diff)

> 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

>
> 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] Updated: (DERBY-680) In ij, executing a prepared statement with numeric/decimal parameter fails with NullPointerException in J2ME/CDC/FP

Posted by "Deepa Remesh (JIRA)" <de...@db.apache.org>.
     [ http://issues.apache.org/jira/browse/DERBY-680?page=all ]

Deepa Remesh updated DERBY-680:
-------------------------------

    Attachment:     (was: derby-680.status)

> 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

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

Posted by "Daniel John Debrunner (JIRA)" <de...@db.apache.org>.
    [ 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] Updated: (DERBY-680) In ij, executing a prepared statement with numeric/decimal parameter fails with NullPointerException in J2ME/CDC/FP

Posted by "Deepa Remesh (JIRA)" <de...@db.apache.org>.
     [ http://issues.apache.org/jira/browse/DERBY-680?page=all ]

Deepa Remesh updated DERBY-680:
-------------------------------

    Attachment:     (was: derby-680_v2.status)

> 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

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

Posted by "Kathey Marsden (JIRA)" <de...@db.apache.org>.
    [ 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] Updated: (DERBY-680) In ij, executing a prepared statement with numeric/decimal parameter fails with NullPointerException in J2ME/CDC/FP

Posted by "Deepa Remesh (JIRA)" <de...@db.apache.org>.
     [ http://issues.apache.org/jira/browse/DERBY-680?page=all ]

Deepa Remesh updated DERBY-680:
-------------------------------

    Attachment: derby-680.diff
                derby-680.status

Attaching a patch 'derby-680.diff'. This patch removes the check "ps.getMetaData().getColumnType(c)" from org.apache.derby.impl.tools.ij.util.java. This was checking ResultSetMetaData, whereas the actual check should be for ParameterMetaData. But ParameterMetaData is not available in JSR169. So currently, get/set String has to be used for all types. With this change, lang/cast.sql does not give NPE. I have added a new master for ejbql.sql. This test was passing because coincidentally ResultSetMetaData and ParameterMetaData were of same type in the statements used. 

With this patch, I ran derbyall with Sun JDK1.4.2 and j9_foundation vm in IBM WCTME5.7. No new failures. Please review/commit 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] Resolved: (DERBY-680) In ij, executing a prepared statement with numeric/decimal parameter fails with NullPointerException in J2ME/CDC/FP

Posted by "Daniel John Debrunner (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/DERBY-680?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Daniel John Debrunner resolved DERBY-680.
-----------------------------------------

       Resolution: Fixed
    Fix Version/s: 10.3.0.0

I believe this was fixed by the changes to ij.util for DERBY-2228. The NPE resulted due to fetching the ResultSetMetaData for an INSERT statement which was of course null. The fixed code no longer uses the ResultSetMetaData which was incorrect anyway.

> In ij, executing a prepared statement with numeric/decimal parameter fails with NullPointerException in J2ME/CDC/FP
> -------------------------------------------------------------------------------------------------------------------
>
>                 Key: DERBY-680
>                 URL: https://issues.apache.org/jira/browse/DERBY-680
>             Project: Derby
>          Issue Type: Bug
>          Components: Tools
>    Affects Versions: 10.2.1.6
>         Environment: j9_foundation VM in IBM WCTME 5.7
>            Reporter: Deepa Remesh
>         Assigned To: Deepa Remesh
>             Fix For: 10.3.0.0
>
>         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.
-
You can reply to this email to add a comment to the issue online.


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

Posted by "Daniel John Debrunner (JIRA)" <de...@db.apache.org>.
    [ 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

Posted by "Deepa Remesh (JIRA)" <de...@db.apache.org>.
    [ 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.44444444444444444444444 )}';

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

Posted by "Deepa Remesh (JIRA)" <de...@db.apache.org>.
    [ 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
>          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

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

Posted by "Deepa Remesh (JIRA)" <de...@db.apache.org>.
    [ 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] Updated: (DERBY-680) In ij, executing a prepared statement with numeric/decimal parameter fails with NullPointerException in J2ME/CDC/FP

Posted by "Deepa Remesh (JIRA)" <de...@db.apache.org>.
     [ http://issues.apache.org/jira/browse/DERBY-680?page=all ]

Deepa Remesh updated DERBY-680:
-------------------------------

    Attachment: derby-680_v2.diff
                derby-680_v2.status

Attaching 'derby-680_v2.diff'. This patch changes the test lang/ejbql.sql as suggested by Dan. Avoids a new master for j9_foundation.

> 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] Updated: (DERBY-680) In ij, executing a prepared statement with numeric/decimal parameter fails with NullPointerException in J2ME/CDC/FP

Posted by "Deepa Remesh (JIRA)" <de...@db.apache.org>.
     [ http://issues.apache.org/jira/browse/DERBY-680?page=all ]

Deepa Remesh updated DERBY-680:
-------------------------------

    Attachment: derby-680_v2.diff
                derby-680_v2.status

lang/cast.sql is failing in J2ME because of some recent additions to the test which require BigDecimal class. Resubmitting the patch without enabling lang/cast.sql.

> 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