Db2

Db2

Connect with Db2, Informix, Netezza, open source, and other data experts to gain value from your data, share insights, and solve problems.

 View Only
Expand all | Collapse all

JT400 Java DB2 strings vs Ecilpse strings

  • 1.  JT400 Java DB2 strings vs Ecilpse strings

    Posted Tue September 24, 2024 07:00 PM

    I have an issue with Java(JT400) strings coming from DB2 to Eclipse.

    When retrieving a string from the DB2 database, into Eclipse they don't match.

    I place it in debug mode the db2 string = "3" and inside eclipse string = "3".

    It doesn't match, the work around is the java method contains(if(menuNumber.contains("3")))

    Why doesn't db2 strng "3" and eclipse strng "3:" match?

    Is it a connection issue or what?

    Please help.



    ------------------------------
    Edward Jurczyk
    ------------------------------



  • 2.  RE: JT400 Java DB2 strings vs Ecilpse strings

    Posted Tue September 24, 2024 08:10 PM
    Edited by Jan Nelken Tue September 24, 2024 08:12 PM

    Hi!

    Stating platform (e.g. Windows, Linux or else) and Db2 version is always helpful;

    output of db2level command?

    What is exact definition of Db2 table columns?

    Output of db2 describe table S.T (where S is schema and T is table name)?

    As for your exact question:

    Why doesn't db2 strng "3" and eclipse strng "3:" match?

    unless it is typo - those strings have different length and content :-)



    ------------------------------
    Jan Nelken
    ------------------------------



  • 3.  RE: JT400 Java DB2 strings vs Ecilpse strings

    Posted Wed September 25, 2024 08:26 AM

    Sorry string are equal "3" db2, eclipse "3"

    Java eclipse says they are not equal. Like I stated the work around is java contains makes it work.

    Why are they not equal?

    Thanks



    ------------------------------
    Edward Jurczyk
    ------------------------------



  • 4.  RE: JT400 Java DB2 strings vs Ecilpse strings

    Posted Wed September 25, 2024 09:44 AM

    Hi!

    Stating platform (e.g. Windows, Linux or else) and Db2 version is always helpful;

    output of db2level command?

    What is exact definition of Db2 table columns?

    Output of db2 describe table S.T (where S is schema and T is table name)?



    ------------------------------
    Jan Nelken
    ------------------------------



  • 5.  RE: JT400 Java DB2 strings vs Ecilpse strings

    Posted Wed September 25, 2024 06:18 PM

    I have no idea what JT400 is.

    Taking a guess, are the database and Java/Eclipse using the same
    character set (codepage or locale)?  Is one UTF and the other ASCII?
    This might give you two characters that look the same but are actually
    different.

    As Jan mentioned, stating the OS and DB versions would be useful.

    scot




  • 6.  RE: JT400 Java DB2 strings vs Ecilpse strings

    Posted Thu September 26, 2024 11:27 AM

    I believe this is true, how do you fix it?

    Is there a connection statement that would fix this?



    ------------------------------
    Edward Jurczyk
    ------------------------------



  • 7.  RE: JT400 Java DB2 strings vs Ecilpse strings

    Posted Thu September 26, 2024 11:39 AM

    Instead of making all of us guessing what seems to be problem - can you at least ask your DBA (I am guessing that you are accessing Db2 for i series - aka Db2/400) what is Database code page, character set and territory?

    I am also guessing that your Eclipse execution environment is using Unicode - but is UTF-8 or other flavors of UTF?



    ------------------------------
    Jan Nelken
    ------------------------------



  • 8.  RE: JT400 Java DB2 strings vs Ecilpse strings

    Posted Thu September 26, 2024 06:19 PM

    As Jan mentioned, check with your DBA for the database side.

    For Eclipse, a quick web search turned up this which shows how/where to
    configure which version of UTF Eclipse uses:

    https://www.baeldung.com/eclipse-utf-8-encoding

    Obviously, the two sides need to be in agreement or you will have problems.




  • 9.  RE: JT400 Java DB2 strings vs Ecilpse strings

    Posted Mon September 30, 2024 09:46 AM

    OS400



    ------------------------------
    Edward Jurczyk
    ------------------------------



  • 10.  RE: JT400 Java DB2 strings vs Ecilpse strings

    Posted Mon September 30, 2024 11:02 AM

    Google translate works fine:



    ------------------------------
    Jan Nelken
    ------------------------------