Oracle returns ¿ instead of unicode characters

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • dzenanz
    New Member
    • Feb 2008
    • 45

    Oracle returns ¿ instead of unicode characters

    Java insert proc:
    Code:
    storedProc = conn.prepareCall("{call SMSC.p_smsu_campaign_insert(?,?,?,?,?,?)}");
    storedProc.setString("Campaign_name", campaign);
    storedProc.setString("Used_OA", OA);
    storedProc.setInt("RefNum", 1);
    storedProc.setString("Send_Start", df.format(new java.sql.Date(startSend)));
    storedProc.setString("Last_VP", df.format(new java.sql.Date(EndDate.getTime() + validity_period)));
    storedProc.setString("Created", df.format(new java.sql.Date(System.currentTimeMillis())));
    storedProc.execute();
    DB insert proc:
    Code:
    create or replace procedure P_SMSU_CAMPAIGN_INSERT (
    Campaign_name in nchar,
    Used_OA in char,
    RefNum in number:=1,
    Last_VP in char,
    Send_Start in char,
    Created in char
    ) is
    begin
      insert into Campaigns (Campaign_name, Used_OA, RefNum, Last_VP, Send_Start, Created)
      values (Campaign_name, Used_OA, RefNum, 
      to_date(Last_VP, 'YYYY-MM-DD HH24:MI:SS'),
      to_date(Send_Start, 'YYYY-MM-DD HH24:MI:SS'),
      to_date(Created, 'YYYY-MM-DD HH24:MI:SS')
      );
    end P_SMSU_CAMPAIGN_INSERT;
    DB table:
    Code:
    create table CAMPAIGNS
    (
      CAMPAIGN_NAME NVARCHAR2(100) not null,
      USED_OA       CHAR(67),
      REFNUM        NUMBER not null,
      LAST_VP       DATE not null,
      SEND_START    DATE not null,
      CREATED       DATE default sysdate not null
    )
    DB select proc:
    Code:
    create or replace procedure P_SMSU_BULK_SUMMARY_STATUS
    (
        RCT1 OUT    GLOBALPKG.RCT1,
    		ReportTimestamp in Timestamp:=null
    ) is
    
    begin
      open rct1 for
      SELECT c.campaign_name, c.used_oa, c.created, c.send_start, c.last_vp
      FROM CAMPAIGNS C
        where (ReportTimestamp between c.created and c.last_vp) or ReportTimestamp is null;
    end P_SMSU_BULK_SUMMARY_STATUS;
    java fetch:
    Code:
    storedProc = conn.prepareCall("{call SMSC.P_SMSU_BULK_SUMMARY_STATUS(?,?)}");
    storedProc.registerOutParameter("RCT1", OracleTypes.CURSOR);
    storedProc.setTimestamp("ReportTimestamp", forTime);
    storedProc.execute();
    ResultSet result = (ResultSet) storedProc.getObject("RCT1");
    return ResultSupport.toResult(result);
    java display:
    Code:
    Object[][] rows = fetch().getRowsByIndex();
    for (int i = 0; i < rows.length; i++)
    {
        out.println("<tr>");
        for (int k = 0; k < rows[i].length; k++)
            out.println("<td>" + encodeHTML(rows[i][k].toString()) + "</td>");
        out.println("</tr>");
    }
    and in the campaign name column I get "¿etvrti test ¿¿¿¿¿ ¿¿¿¿¿" instead of "četvrti test šđčćž ŠĐČĆŽ" (which I entered). Function encodeHTML gets crap as parameter, so html encoding is not the problem.

    Platform ojdbc1.4 + oracle10g. What am I doing wrong?
  • JosAH
    Recognized Expert MVP
    • Mar 2007
    • 11453

    #2
    Originally posted by dzenanz
    and in the campaign name column I get "¿etvrti test ¿¿¿¿¿ ¿¿¿¿¿" instead of "četvrti test šđčćž ŠĐČĆŽ" (which I entered). Function encodeHTML gets crap as parameter, so html encoding is not the problem.

    Platform ojdbc1.4 + oracle10g. What am I doing wrong?
    The ASCII characters come through fine. My guess is that the font you're using
    can't display the glyphs (shape) of the non-ASCII characters. Try the Arial MS
    Unicode font (if you have it installed) for starters.

    kind regards,

    Jos

    Comment

    • dzenanz
      New Member
      • Feb 2008
      • 45

      #3
      It is not that. When I check the received string in the debugger, it contains crap characters (code point 191), and they get displayed properly (with inverted question mark)

      Comment

      • dzenanz
        New Member
        • Feb 2008
        • 45

        #4
        I have rechecked, and crap characters are stored in database, so the insertion part skrews up.

        At the statement
        Code:
        storedProc.setString("Campaign_name", campaign);
        variable campaign contains correct string (netbeans debugger displays it correctly).

        Also, when I access db from Visual Studio (either direct access to table or through insert procedure), everything is fine!

        Java part correctly shows unicode characters inserted/modified by program written in Visual Studio! So, I have narrowed the problem to the insertion part:
        Code:
        storedProc = conn.prepareCall("{call SMSC.p_smsu_campaign_insert(?,?,?,?,?,?)}");
        storedProc.setString("Campaign_name", campaign);
        storedProc.setString("Used_OA", OA);
        storedProc.setInt("RefNum", 1);
        storedProc.setString("Send_Start", df.format(new java.sql.Date(startSend)));
        storedProc.setString("Last_VP", df.format(new java.sql.Date(EndDate.getTime() + validity_period)));
        storedProc.setString("Created", df.format(new java.sql.Date(System.currentTimeMillis())));
        storedProc.execute();

        Comment

        Working...