If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Database Server Software > DB2 > Exception when retrieving accent characters from DB2 using Java

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 04-30-06, 19:09
Tiger-SB Tiger-SB is offline
Registered User
 
Join Date: Apr 2006
Posts: 1
Exception when retrieving accent characters from DB2 using Java

Hi everyone,

I've recently come across a problem where I get an unknown SQLException in my Java application when trying to retrieve a String from my DB2 database which contains some French accent characters. But, if I run the same SQL statement (without '?' parameters of course), I get the correct description displayed.

Please see below for relevent technical information.

Any ideas on what the problem is and how to fix it would be greatly appreciated.

Regards,
Tiger

Server OS: SUSE Linux, Enterprise Server 9
DB2 version: v8.1.2.96
Fixpack: 10
DB2 Type: WSE
Java version: jdk1.5.0_05

Relevent Java Code
Code:
    CallableStatement cStmt = null;
    ResultSet rs = null;
    try {
        Connection con = getConnection();
        String sql =  "SELECT description FROM errormessage WHERE errorCode = ? and languageCode = ?";
        cStmt = con.prepareCall(sql, ResultSet.TYPE_FORWARD_ONLY, ResultSet.CONCUR_READ_ONLY );
        cStmt.setString(1, "E123");
        cStmt.setString(2, "FRA");
        rs = cStmt.executeQuery();
        if (rs.next()) {
            String description = rs.getString(1);
            System.out.println("Translated errormessage = " + description);
        }
    } catch (SQLException e) {
        System.out.println("Exception caught. Exception Msg: " + e.getMessage());
        System.out.println("SQL ErrorCode = " + e.getErrorCode() + ", SQL State = " + e.getSQLState())
        e.printStackTrace();
    } finally {
        close(rs);
        close(cStmt);
        closeConnection();
    }
}
SQLException and Stacktrace
Code:
    Exception caught. Exception Msg: null
    SQL ErrorCode = -99999, SQL State = null
    com.ibm.db2.jcc.b.SqlException
            at com.ibm.db2.jcc.b.r.a(r.java:1564)
            at com.ibm.db2.jcc.b.r.m(r.java:483)
            at com.ibm.db2.jcc.b.r.M(r.java:1198)
            at com.ibm.db2.jcc.b.rc.getString(rc.java:887)
            at DatabaseTest.test(DatabaseTest.java:140)
            at DatabaseTest.main(DatabaseTest.java:47)
DB2 Table: ErrorMessage
Code:
    Column                         Type      Type
    name                           schema    name               Length   Scale Nulls
    ------------------------------ --------- ------------------ -------- ----- ------
    ERRORMESSAGEID                 SYSIBM    INTEGER                   4     0 No
    ERRORCODE                      SYSIBM    CHARACTER                 6     0 No
    LANGUAGECODE                   SYSIBM    CHARACTER                 6     0 No
    DESCRIPTION                    SYSIBM    VARCHAR                 256     0 No
Relevent Database Configuration
Code:
    Database territory                                      = US
    Database code page                                      = 1208
    Database code set                                       = UTF8
    Database country/region code                            = 1
SQL Statement and Result when run from the Command Line
Code:
    SELECT description FROM errormessage WHERE errorCode = 'E123' and languageCode = 'FRA'

    DESCRIPTION
    -------------------------------------------------------------------------------------------------------------
    Lidentité de lunité saisie est incorrecte*; veuillez vérifier celle-ci sur lécran A propos de puis réessayez.
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On