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.


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
    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())
    } finally {
SQLException and Stacktrace
    Exception caught. Exception Msg: null
    SQL ErrorCode = -99999, SQL State = null
            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
    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
    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
    SELECT description FROM errormessage WHERE errorCode = 'E123' and languageCode = 'FRA'

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