Topic
  • 3 replies
  • Latest Post - ‏2013-05-01T20:23:25Z by SanjaySingh72
SystemAdmin
SystemAdmin
1731 Posts

Pinned topic AS400PackedDecimal Throwing NumberFormatException

‏2007-06-07T13:26:09Z |
I'm using the Java Toolbox (JDBC) to connect to DB2 to call an RPG program.

The RPG program returns the following data structure
codeDDs DS OCCURS(maxrecs) QUALIFIED
D FIELD1 4
D FIELD2 52
D FIELD3 1
D FIELD4 4P 0 [/code]
Connect to the RPG program using a connection and the following jdbc code
code
Connection cnn = DataUtility.getConnection("dsName");
CallableStatement stmt = cnn.prepareCall("call lib.prog");
ResultSet rst = stmt.executeQuery();
[/code]
Whenever I try to retrieve a value from column 4 (FIELD4) from the resultset, the program throws the following exception:
code6/7/07 9:09:51:065 EDT 00000029 WebApp E SRVE0026E: Servlet Error-testall: java.lang.NumberFormatException: 3125
at com.ibm.as400.access.AS400PackedDecimal.toObject(AS400PackedDecimal.java:517)
at com.ibm.as400.access.SQLDecimal.convertFromRawBytes(SQLDecimal.java:89)
at com.ibm.as400.access.JDServerRow.getSQLData(JDServerRow.java:400)
at com.ibm.as400.access.AS400JDBCResultSet.getValue(AS400JDBCResultSet.java:3625)
at com.ibm.as400.access.AS400JDBCResultSet.getObject(AS400JDBCResultSet.java:3028)
at com.ibm.ws.rsadapter.jdbc.WSJdbcResultSet.getObject(WSJdbcResultSet.java:1492)
[/code]

If you need any more information, just let me know. Any help would be appreciated.
Updated on 2007-10-18T19:03:50Z at 2007-10-18T19:03:50Z by SystemAdmin
  • SystemAdmin
    SystemAdmin
    1731 Posts

    Re: AS400PackedDecimal Throwing NumberFormatException

    ‏2007-06-07T14:45:00Z  
    Okay, I fixed the problem.

    It had to do with the data structure initializing the packed decimal as some weird random number. Fixed by initializing the value in the data structure.
    codeD FIELD4 4P 0 INZ(*zeros)[/code]
  • SystemAdmin
    SystemAdmin
    1731 Posts

    Re: AS400PackedDecimal Throwing NumberFormatException

    ‏2007-10-18T19:03:50Z  
    Okay, I fixed the problem.

    It had to do with the data structure initializing the packed decimal as some weird random number. Fixed by initializing the value in the data structure.
    codeD FIELD4 4P 0 INZ(*zeros)[/code]
    Since the expception thrown was a Java Exception. Could you share how your Data structure and inititalization looks like in Java?

    Thanks.
  • SanjaySingh72
    SanjaySingh72
    1 Post

    Re: AS400PackedDecimal Throwing NumberFormatException

    ‏2013-05-01T20:23:25Z  
    Okay, I fixed the problem.

    It had to do with the data structure initializing the packed decimal as some weird random number. Fixed by initializing the value in the data structure.
    codeD FIELD4 4P 0 INZ(*zeros)[/code]

    Can you please give me the exact code in java that you used to fix the problem when you say that used some kind of initialization. I am facing the same issue at my end.