Trouble in writing Chinese Characters into database

I'm developing a JSP web site using ACCESS2002, Tomcat4.0.4 and J2EE 1.4.1. I found my data(chinese chatacters) in mess when I wrote it in to database through sun's own JDBC-ODBC driver though it is displayed correctly in web-browser. I tried in JSP, Servlet and JavaBean, and the situation seems no better.
Is it the problem of sun's JDBC-ODBC driver or is there a solution to this problem?
Eager to hear a reply, thank millions!!

Have you tried something like the following?
first, set this page quality:
<%@ page contentType="text/html;charset=Big5"%>
then, change the Chinese string to this:
String zhtounicode=new String(yourzhstring.getBytes("8859_1"));
then, do with the converted string.

Similar Messages

  • Pls help.JSP: I could not store Chinese characters into files.

    Hi experts,
    I have this problem of cant store chinese characters into files(eg. .txt and .properties). I am adding
    these chinese text through a JSP website form....After i key in chinese characters in the textboxes
    in the website and sumbit the results, my chinese characters turned into ASCII or rather garbage in
    the files.
    Is there any way i can get the exact chinese characters i entered in the webite into the files?
    Need urgent assistance here.
    Thanks
    <%@ page contentType="text/html; charset=big5" %>
    <html>
    <head>
    <title>Confirmation</title>
    <meta http-equiv="Content-Type" content="text/html; charset=big5">
    <META HTTP-EQUIV="Pragma" CONTENT="no-cache">
    </head>
    <%@ page language="java"%>
    <%@ page import="java.io.*"%>
    <%@ page import="java.lang.Integer.*"%>
    <%@ page import="java.sql.*"%>
    <%@ page import="java.sql.ResultSet.*"%>
    <%@ page import="javax.servlet.*"%>
    <%@ page import="javax.servlet.http.*"%>
    <%@ page import="java.text.*"%>
    <%@ page import="java.util.*"%>
    <%@ page import="java.net.URL"%>
    <%
    //getting attributes from previous page form
    //At this point, chinese characters r retrieved
    //Ascii/garbage displayed for text when retrieved from previous page.
    String gameName=request.getParameter("name");
    String encode=request.getParameter("encode");
    String gameType=request.getParameter("type");
    String info=request.getParameter("description");
    int check=0;
    int nextGameID;
    String temp="";
    String langCode="";
    //establish connection
    Connection con = null;
    try {
    Class.forName("org.postgresql.Driver");
    con = DriverManager.getConnection("jdbc:postgresql://172.20.134.110:5432/smsINTFET" , "postgres",
    "postgres");
    catch(ClassNotFoundException e) {
    out.println("Could not load the driver: "+e.getMessage());
    catch(SQLException e) {
    out.println("SQLException caught in relax db: "+ e.getMessage());
    Statement stmt = null;
    ResultSet rs = null;
    ResultSet ps = null;
    String strSQL = "";
    String strSQL2 = "";
    String tempCat = "";
    strSQL="SELECT gamename FROM cp_games order by gameid;";
    try {
    stmt = con.createStatement();
    rs = stmt.executeQuery(strSQL);
    stmt.close();
    catch(SQLException e) {
    out.println("SQLException caught: "+ e.getMessage());
    while(rs.next())
    check=0;
    temp=rs.getString("gamename");
    if(temp.equalsIgnoreCase(gameName))
    // there is similar record in database
    check=1;
    break;
    else
    check=0;
    if(check==0)
    %>
    <body background="button/bkgd.jpg" bgproperties="fixed">
    <p><b><font size="30pts" face="Monotype Corsiva">Confirmation</font></b></p>
    <HR style="WIDTH: 500px; COLOR: blue; HEIGHT: 3px">
    The following information has been added.
    <table width="75%" border="0" cellspacing="0" cellpadding="2">
    <%
    String strCat="";
    strCat="INSERT INTO cp_games(gamename,description,encode) values('"+gameName+"','"+info+"','"+encode+"');";
    stmt = con.createStatement();
    stmt.executeUpdate(strCat);
    System.out.println("Successful inserted category");
    stmt.close();
    //setting language
    if(encode.equals("ascii"))
    langCode = "US";
    if(encode.equals("ms950"))
    langCode = "TW";
    if(encode.equals("ms936"))
    langCode = "CN";
    strSQL2="SELECT gameid FROM cp_games where gamename = '"+gameName+"';";
    try {
    stmt = con.createStatement();
    ps = stmt.executeQuery(strSQL2);
    stmt.close();
    catch(SQLException e) {
    out.println("SQLException caught: "+ e.getMessage());
    ps.next();
    nextGameID=ps.getInt("gameid");
    out.println("<B>The game number : </B>" + nextGameID);
    %>
    <tr>
    <td><B>Game added: </B><%=gameName%>
    </td>
    </tr>
    </table>
    <%
    String newFile="G:\\home\\smsGamesINTV2\\colorGame\\propertiesFiles\\FET\\CP_Game"+nextGameID+"_"+encode+"_"+langCode+".properties";
    try
    {               //begin file
    PrintWriter outFile=null;
    //create a new file and write the initial settings to file
    outFile=new PrintWriter(new FileOutputStream(newFile,true));
    outFile.println("game_intro="+nextGameID+")"+gameName+" - "+info);
    outFile.println("");
    outFile.println("game_title="+gameName);
    outFile.println("");
    outFile.println("game_type="+gameType);
    outFile.println("");
    outFile.println("qns_no=0");
    outFile.println("");
    outFile.println("ana_no=0");
    outFile.close();
    }//end file
    catch(IOException e)
    out.println("File Create Error");
    else // no match found
    out.println("Game,"+temp+ " already added");
    %>
    </body>
    </html>

    try to add this code under this line:
    <%@ page contentType="text/html; charset=big5" %>
    <% response.setContentType("text/html; charset=big5"); %>
    I have faced the problem like yours and it works fine for me. Try and see.

  • Unable to insert Chinese characters in Database

    My problem is that I am not able to insert chinese
    (to traditional chinese) characters into my tables in the
    database.
    I have changed the character set to UTF8 while creating the
    database and also tried the alter session command in SQL to
    alter the NLS_LANGUAGE and NLS_TERRITORY (to say traditional chinese).
    But this did not solve my problem.
    Also tried all possibilites like getting Chinese characters
    in my notepad by copy - paste from a Chinese web site
    but while giving the insert into command in my database
    it takes some junk values.
    Someone PLEASE HELP!!!URGENT!!!
    Thanks in advance.
    RKP
    null

    You mentioned in your first note that you have set your database character set to UTF-8? If so, then you are able to store and retrieve multilingual data, including Chinese and Japanese characters. Your issue is not the database. Your client OS must be able to support these languages as well. It is likely that your version of OS supports only Latin and Western European characters. By the way changing your NT regional setting only effects sorting, date formats etc. It doesn't help you change the languages that your keyboard will support.
    1.To determine your Win32 operating system's current ANSI CodePage (ACP). This can be found by bringing up the registry editor (Start --> Run..., type "regedit.exe", and click "OK") and looking at the
    registry entry HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Nls\CodePage\ACP (there are many registry entries with very similar names, so please make sure that you are looking at the right place in the registry).
    2.To find the character set in the table below based on the ACP you got above.
    ANSI CodePage (ACP) Client character set (3rd part of NLS_LANG) (*1)
    1250 EE8MSWIN1250
    1251 CL8MSWIN1251
    1252 WE8MSWIN1252
    1253 EL8MSWIN1253
    1254 TR8MSWIN1254
    1255 IW8MSWIN1255
    1256 AR8MSWIN1256
    1257 BLT8MSWIN1257
    1258 VN8MSWIN1258
    874 TH8TISASCII
    932 JA16SJIS
    936 ZHS16GBK
    949 KO16MSWIN949
    950 ZHT16MSWIN950
    others UTF8 (*2)
    (*1) The character sets listed here are compatible with Win32's non-Unicode graphical user interface (GUI). Since Win32's MSDOS Box (Command Prompt) uses different character sets, NLS_LANG needs to be manually set in the MSDOS Box (or set in a batch script) in order to handle the difference
    between Win32's GUI and MSDOS Box. (Please see "NLS_LANG Settings in MS-DOS Mode and Batch Mode" in the Oracle8i Installation Guide Release 2 (8.1.6) for Windows NT, part# A73010-01.)
    (*2) If you use UTF8 for the 3rd part of NLS_LANG on Win32, client programs that you can use on this operating system would be limited to the ones that explicitly support this configuration. Recent versions of Oracle Forms' Client/Server mode (Fat-Client) on NT4.0 would be an example of such client
    programs. This is because the user interface of Win32 is not UTF8, therefore the client programs have to perform explicit conversions between UTF8 (used in Oracle side) and UTF16 (used in Win32 side).

  • Writing chinese character into a file

    Hi,
    I need to write chinese characters into a file,I used FileOutputStream, using the method write(byte[] b)...
    whereby I will convert the chinese word into bytes....
    but it couldn't work...
    Please Help!!

    you can write the unicode hex string (e.g. 606D559C53D18D22 for Gong Xi Fa Chai) into a text file by using the following code
              PrintWriter out2 = new PrintWriter(new BufferedWriter(new OutputStreamWriter(new FileOutputStream("chinese_out.txt", false), "UTF-8")));
                   int countChineseChar = chineseHex.length()/4;
                   int index = 0;
                   String c = "";
                   int b;
                   for(int i=0; i<countChineseChar-1; i++)
                        c = new String(chineseHex.substring(index, index+4));
                        b = Integer.parseInt(c, 16);
                        out2.write(b);
                        index+=4;
    Note that the OutputStreamWriter uses the UTF-8 to encode the unicode hex. I'm assuming that the hex is fixed at 4 digits each character
    syam

  • Input Simplified Chinese Characters into Microsoft Powerpoint

    Please help!
    What's the easiest way to put Simplified Chinese Characters into Microsoft Powerpoint???
    I have a mandarin project due like in a week, and I've been trying to find out how to do this on a mac. I've tried the international thing on preferences, but it doesn't work very well, and doesn't even work on powerpoint. Any help would be awesome!!!!
    Cheers!

    the characters turn out as wierd symbols
    You should really have no problem with Office 2004. You might make sure you have the MS Chinese Fonts selected for your text field (SimSun.ttf and PMingLiU.ttf. They appear in the Font menu as 宋体 and 新細明體.)
    Send me a screenshot if you like (tom at bluesky dot org).
    If problems continue, you can ask in the Chinese-Mac group:
    http://groups.google.com/group/chinesemac/
    or the MS PowerPoint group:
    http://groups.google.com/group/microsoft.public.mac.office.powerpoint/topics

  • Chinese characters into Motion

    Hi all,
    I need to import Chinese characters into a Motion project I'm doing. Can anyone help with this. I can't find a way to import the Chinese character set which comes with Apple OS.
    Thanks in advance, M

    I can't find a way to import the Chinese character set which comes with Apple OS.
    Are you familiar with how one inputs Chinese? If so, does it not work right? See this site:
    http://www.yale.edu/chinesemac/pages/input_methods.html#Apple

  • How to configure my Firefox thus allowing me to input Chinese characters into the search box by using PenPower writing pad while this problem doesn't exist when I am using Internet Explorer?

    I am using the electronic writing pad made by PENPOWER Inc. to input Chinese characters onto my PC programs (e.g. Winword, Internet Explorer, Excel, etc.) But I can not make it happened on Firefox, please advice what I have to do with the configuration of the Firefox or using any other method to make it work. Thanking you guys in advance for helping me to solve this problem.

    cor-el,
    Thank you very much for your advice. The new software of Penpower works rightaway after I installed it on my pc. Thanks again.
    十分感激你的幫忙!

  • Entry of non-English characters into database

    Hi
    We are facing a problem in inserting non-English characters into the database.For example, we have a company name field which can accept German characters. This field has been defined as of varchar2 type of size 50 in the db. When we enter 49 English characters and then one German character, the database is throwing the error that the inserted value is too large for the column.Is it that the German character is taken as equivalent to two English characters ? Or is there any database level setting that can be done for this ? For the time being we have identified certain critical fields and have doubled the size of their fields in the db. But I guess there has to be another solution to this....
    Please help.
    TIA
    Vinoj

    Indeed, your German character is using two bytes to store itself. Consult the Oracle JDBC Developer's Guide.
    null

  • Reg : Pull Chinese characters into XLS

    Hi Experts,
    I have to generate a report by pulling from tables to an Excel sheet.
    But i'm getting the Chinese characters as junk.
    FYI - I'm using PERL script for this report generation.
    Any idea regarding this ?
    TIA.
    Best Regards,
    Ranit B.

    ranitB wrote:
    Hi Experts,
    I have to generate a report by pulling from tables to an Excel sheet.
    But i'm getting the Chinese characters as junk.
    FYI - I'm using PERL script for this report generation.
    Any idea regarding this ?
    TIA.
    Best Regards,
    Ranit B.is problem a data storage issue or data presentation issue?
    SELECT ASCIISTR(CHINESE_COL) FROM YOUR_TABLE WHERE ID = 1;

  • Insert chinese big5 characters into database

    database: mysql
    default charset of web page: utf-8 (specified in apache, all
    pages are in utf-8)
    if I enter english, database insert is ok but if I enter
    chinese, error = "You have an error in your SQL syntax; check the
    manual that corresponds to your MySQL server version for the right
    syntax to use near '?, ?)' at line 1"
    display inputted fields are OK.
    *** form.cfm ***
    <form action="insert.cfm" method="post">
    name: <input type="text" name="name"
    value=""><BR>
    Password: <input type="text" name="password"
    value=""><BR>
    <input type="submit" name="login_user"
    value="insert"><BR>
    </form>
    *** insert.cfm ***
    <cfoutput>
    #Form.name#<Br>
    #form.password#<br>
    </cfoutput>
    <cfquery name="insert" datasource="test">
    insert into test (name,password) values ('#Form.name#',
    '#Form.password#')
    </cfquery>

    dynason wrote:
    > database: mysql
    > default charset of web page: utf-8 (specified in apache,
    all pages are in
    > utf-8)
    what version of cf5? what version of mysql? has to be at
    least 4.1. is the db,
    etc. setup to handle that encoding? do you really want to use
    BIG5 instead of
    unicode? what db driver? it can't be ODBC.

  • Reading and Writing from XML into database

    Dear all,
    We have a requirement where we have to upload data to FTP location in XML files, and then read from this into our database daily 2-3 times a day.
    We have oracle 11g database, can someone kindly guide me how we can acheive this.
    Also is there any tool for this? my management is thinking of purchasing one if it exists.
    thank you

    user10243788 wrote:
    Thank you miheal,
    is there any tool also we can use?The person I turn to for ideas about XML going into and out of the database is Marco Gralike.
    Here's a sample (a couple of years old now) from his blog of mixing XML and SQL: http://www.liberidu.com/blog/2010/07/29/external-views-xml-based/
    It's the first one I happened to get to when I did a search on his blog for: external table.
    Some time back he sent me an example of running an SQL statement from the database which accessed the internet and pulled back the content of one of my blog pages in a form that would allow me to do: "insert into table select from {XML call}"
    Unfortunately I can't find the code right now - I know I stored it somewhere to make sure I didn't lose it but ...
    Regards
    Jonathan Lewis

  • Inserting all manner of characters into database

    Hello friends,
    Consider this code snippet of mine:
    String sentence = "My name is nameless aka 'anonymous' or \"anonymous\" ('did I hear that? Maybe!! now where were we?') -\"yawn! Am bored..."; PreparedStatement statement = connection.prepareStatement("insert into tenonly(name) values('" + sentence + "')"); statement.executeUpdate();  // THIS IS LINE 38{code} And consider the stack trace: {code}init: deps-jar: Compiling 1 source file to /home/arthur/portal/MaintainTenEntries/build/classes compile: run: java.sql.SQLException: No value specified for parameter 1         at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:910) DONE         at com.mysql.jdbc.PreparedStatement.fillSendPacket(PreparedStatement.java:1534)         at com.mysql.jdbc.PreparedStatement.executeUpdate(PreparedStatement.java:1375)         at com.mysql.jdbc.PreparedStatement.executeUpdate(PreparedStatement.java:1318)         at com.mysql.jdbc.PreparedStatement.executeUpdate(PreparedStatement.java:1303)         at maintaintenentries.Main.main(Main.java:38) BUILD SUCCESSFUL (total time: 13 seconds){code} Could anyone please inform me of my  wrong turn? Thanks                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   

    Jamwa wrote:
    Hello friends,
    Consider this code snippet of mine:
    String sentence = "My name is nameless aka 'anonymous' or \"anonymous\" ('did I hear that? Maybe!! now where were we?') -\"yawn! Am bored...";
    PreparedStatement statement = connection.prepareStatement("insert into tenonly(name) values('" + sentence + "')");
    statement.executeUpdate();  // THIS IS LINE 38{code}Consider how you're misusing PreparedStatement. It escapes Strings properly for you, yet you aren't using it to do so.
    The right way is:
    {code}
    String sentence = "My name is nameless aka 'anonymous' or \"anonymous\" ('did I hear that? Maybe!! now where were we?') -\"yawn! Am bored...";
    PreparedStatement statement = connection.prepareStatement("insert into tenonly(name) values(?)");
    statement.setString(1, sentence);
    statement.executeUpdate(); // THIS IS LINE 38

  • How to enable "Change characters to Chinese Traditional" and "Change characters into Chinese Simplified" ?

    I am a Taiwanese and usually use the feature of "Change characters into Chinese Traditional" or "Change characters into Chinese simplified" . Before I update Pages/Numbers/Keynotes , these features works well . I can transfer Chinese characters into Traditional or Simplified in the menu of Pages -> services .
    But After I upgreade OS to Mavericks , and Pages to 5.0 , Numbers to 3.0 and keynotes to 6.0 , the features are removed by Apple. I just call Apple expert service in China and they said : The features confirmed to been removed .
    Is there any expert can teach me recover the feautre manually or down-grade to old version of Pages/Numbers/Keynotes ?
    I need the features ..... Please help !!!!!!
    Best Regard, Tommy
    <Email Edited by Host>

    Services is broken on the new Pages, you could use TextEdit instead until Apple produces a fix.  To encourage the latter, tell them you want this back via
    http://www.apple.com/feedback

  • Why aren't handwritten chinese characters showing up in applications?

    I'm on a 13" MacBook Pro, running OS X 10.9.4. I have activated [Pinyin - Simplified] in my input sources, and I have activated the option for TrackPad handwriting. Typing the pinyin and choosing the right character works fine, but I haven't been able to input chinese characters into any document via the trackpad writing method. I am able to pull up the "slate" thing, write, and choose a character, but the character just doesn't show up in the application. I've tried it with TextEdit, Word, and Safari.

    You might try asking at
    https://groups.google.com/forum/#!forum/chinesemac
    or if you know chinese well, at
    https://discussionschinese.apple.com/

  • Cannot insert Chinese character into nvarchar2 field

    I have tested in two environments:
    1. Database Character Set: ZHS16CGB231280
    National Character Set: AL16UTF8
    If the field type of datatable is varchar2 or nvarchar2, the provider can read and write Chinese correctly.
    2. Database Character Set:WE8MSWIN1252
    National Character Set: AL16UTF8
    The provider can not read and write Chinese correctly even the field type of datatable is nvarchar2
    I find that for the second one, both MS .NET Managed Provider for Oracle and Oracle Managed Data Provider cannot read and write NCHAR or NVARCHAR2 fields. The data inserted into these fields become question marks.
    Even if I changed the NLS_LANG registry to SIMPLIFIED CHINESE_CHINA.ZHS16CGB231280, the result is the same.
    For the second situation, only after I change the Database Character Set to ZHS16CGB231280 with ALTER DATABASE CHARACTER SET statement, can I insert Chinese correctly.
    Does any know why I cannot insert Chinese characters into Unicode fields when the Database Character Set is WE8MSWIN1252? Thanks.
    Regards,
    Jason

    Hi Jason,
    First of all, I am not familiar with MS .NET Managed Provider for Oracle or Oracle Managed Data Provider.
    How did you insert these Simplified Chinese characters into the NVARCHAR2 column ? Are they hardcoded as string literals as part of the SQL INSERT statement ? If so, this could be because, all SQL statements are converted into the database character set before they are parsed by the SQL engine; hence these Chinese characters would be lost if your db character set was WE8MSWIN1252 but not when it was ZHS16CGB231280.
    Two workarounds, both involved the removal of hardcoding chinese characters.
    1. Rewrite your string literal using the SQL function UNISTR().
    2. Use bind variables instead of text literals in the SQL.
    Thanks
    Nat

Maybe you are looking for

  • VDI 3.1 EA - Internal Error when assigning a user to a pool

    Hello: I'm hoping somebody can help point me in the right place to troubleshoot this. I'm using OpenLDAP and I've changed my LDAP filters so I can search for the users but when I select the user and click on the 'OK' button, it pukes out with an Inte

  • WMA (Windows Media) files not being stored in a blob

    Running APEX 3.2.1.00 Oracle 11g (I think) Running IE7 I have a simple application for users to store files (upload a blob file type). With .WAV files, it works wonderfully. Users can upload the audio file and play it back as a mime type through Wind

  • Repository Creation Assistant installation problem

    I am following the steps in http://download.oracle.com/docs/cd/E14571_01/install.1111/e12002/sso_das002.htm to install Oracle SSO for OID 11g. In step 3, it require to use RepCA (repository creation assistant) to load SSO so I go ahead to install Rep

  • Understand Telstra Air data use

    Telstra Air® data usage and your bill Telstra Air will appear on the data usage page of your bill. Telstra Air membership is included in your nominated eligible broadband service and all data that you use at Telstra Air and Fon hotspots counts toward

  • Why can't iPad connection speed surpass 72/150 Mbs?

    The iPad boasts 5 antennas. But It seems only 1 or 2 antennae are enabled to work. I put my iPad right beside the Airpot Extreme router, the connection speed via 802.11a/n at 5GHz never exceeds 72MB, no matter how close it is to the base station. My