This discussion is archived
7 Replies Latest reply: Jul 20, 2005 8:56 AM by 843810 RSS

How to store Unicode in Oracle database ?

843810 Newbie
Currently Being Moderated
I have a J2EE application and currently we are storing the Unicode data in &#xxxx; format.

The browser can display this properly but the java swing application cannot. So I need to convert this to \uxxxx format.

Is it advisable to store the data in the d/b in the \uxxxx format or &#xxxx; format ? Advantages ? Disadvantages ?

The database is setup for UTF-8.

Thanks
  • 1. Re: How to store Unicode in Oracle database ?
    843810 Newbie
    Currently Being Moderated
    Sorry the amp;# missed out.

    I have a J2EE application and currently we are storing the Unicode data in amp;#xxx; format.

    The browser can display this properly but the java swing application cannot. So I need to convert this to \uxxxx format.

    Is it advisable to store the data in the d/b in the \uxxxx format or amp;#xxx; format ? Advantages ? Disadvantages ?

    The database is setup for UTF-8.

    Thanks
  • 2. Re: How to store Unicode in Oracle database ?
    843810 Newbie
    Currently Being Moderated
    I suggest you store the data in the database in its native format.
    Most databases support unicode (16-bit) characters by default. WHich database are you using?
  • 3. Re: How to store Unicode in Oracle database ?
    843810 Newbie
    Currently Being Moderated
    I am using Oracle.

    Could you please elaborate on the "native format" ?

    Thanks
  • 4. Re: How to store Unicode in Oracle database ?
    843810 Newbie
    Currently Being Moderated
    If you use JDBC to send data to the database, it will take care of any necessary transformations. Just send the data as a String and, assuming your database is set up for Unicode properly, you will safely store a Unicode string. There's no need to use escape sequences or HTML entities. In fact, these are a bad thing because the database won't know they are Unicode. It will just see a sequence of ASCII characters. I recommend reading the JDBC tutorial.
  • 5. Re: How to store Unicode in Oracle database ?
    843810 Newbie
    Currently Being Moderated
    I agree with the general statement in this draft FAQ from w3.org:
    It is almost always preferable to use an encoding that allows you to >represent the characters in their normal form, rather than using character >entities or NCRs.
    ( http://www.w3.org/International/questions/qa-escapes )

    So I would say the choice should not be between storing the characters as NCRs or Unicode escape sequences, but rather between storing them as normal UTF-8 or escape sequences.

    I would normally recommend storing the characters simply as UTF-8 encoded, mainly because that will ensure that you don't have to perform conversion if you have to interface with other DBs or with other middleware. So I would recommend implementing a native2ascii conversion on the characters when they are extracted (if that is possible).
  • 6. Re: How to store Unicode in Oracle database ?
    843810 Newbie
    Currently Being Moderated
    I am using JDBC API to store data in the database and it is storing in native format. I have no problem to retrieve it from base using the JDBC API. For me as part of master data, i need to execute some SQL statements. Is there any way to insert native format to database using insert query and that should also be easily convertible by JDBC as in case of other native format data stored from application.
  • 7. Re: How to store Unicode in Oracle database ?
    PhHein Guru Moderator
    Currently Being Moderated
    Please don't post to years old threads. Start your own threads instead of hijacking others.

    Locking.