Results 1 to 2 of 2
  1. #1
    Join Date
    Mar 2004
    Posts
    5

    Unanswered: oracle character set

    now my oracle db server and weblogic app server is both at win2000 japanese edition, their os default charset is shift_jis, and db server and client's charset are both JAPANESE_JAPAN.JA16SJIS. but the db server's NCHAR charset is al16utf16.
    so i think i can insert any unicode character into db Nvarchar2 field from my java application using jdbc. but fact is: if the char all in japanese, it work ok; when i try to insert chinese char into nchar field, the char in db is confused.
    i don't know which step confused the transmition.
    perhaps, jdbc convert the java unicode string into japanese language, and put it in db, then the db translate it into unicode nchar field. so some information of char is missed in conversion.
    but i think there is some way in which we can transmit the java unicode string directly into db ncha fields, how to do it?

    Properties prop = new Properties();
    File f = new File("C:\\Toclass\\eclipseProject\\forum\\p.proper ties.y");
    prop.load(new FileInputStream(f));
    String s = prop.getProperty("shuru");
    prop.list(System.out);
    //request.setCharacterEncoding("shift_jis");
    //byte[] b = {(byte)0x93, (byte)0x8F, (byte)0x65, (byte)0x51};//UNICODE?入
    //String s = new String(b,"UTF-16LE");
    System.out.println("********* s="+s);
    String s1 = new String("befor insert to db: " + s);

    byte[] b2 = s.getBytes("utf-16");
    for (int y=0;y<b2.length;y++) System.out.println(b2[y]);

    DbAccess db = new DbAccess();
    ResultSet rs;
    String s2;
    String s3;
    String s4;
    try{
    //db.getStatement().executeQuery("insert into msg(m1,m2,m3) values(\'" +
    //s + "\',\'" + s + "\',\'" + "938f6551" + "\')");
    CallableStatement cs = db.getConnection().prepareCall("{ call insertNchar(?) }");
    //cs.setBytes(1,b2);
    cs.setString(1,s);
    //cs.setUnicodeStream(1,new ByteArrayInputStream(b2),b2.length);
    cs.execute();

    rs = db.getStatement().executeQuery("select m1 from msg");
    rs.next();
    s2 = rs.getString("m1");//"from db m1 = " +
    //s3 = "from db m2 = " + rs.getString("m2");

    byte[] bytes = s2.getBytes("utf-16");
    for (int x=0;x<bytes.length;x++){
    System.out.println(bytes[x]);
    }
    //s4 = "from db m3 = " + new String(bytes,"utf-16");
    //String s5 = new String("txt in code: " + "?入");


    response.setContentType("text/html; charset=utf-16");
    PrintWriter out = response.getWriter();
    //<meta http-equiv=\"Content-type\" content=\"text/html; charset=gb2312\">
    out.println("<html><head></head><body>");

    out.println(s1+"<br>");
    out.println(s2+"<br>");
    //out.println(s3+"<br>");
    //out.println(s4+"<br>");
    //out.println(s5+"<br>");

    out.println("</body></html>");
    }catch(Throwable t){
    System.out.println("error");
    t.printStackTrace();
    }
    prop.clear();
    }

  2. #2
    Join Date
    Jan 2003
    Location
    Vienna, Austria
    Posts
    102
    hi,

    I doesn't know much about the details of asian character sets, so please don't blame me, if I'm wrong.
    are the chinese characters part of the JA16SJIS character set? If not, your java-program will send chinese characters, but the database will see these as part of the JA16SJIS codepage and store it as a JA16SJIS-to-AL16UTF16 representant.
    Maybe you can tra to use other NLS_LANG settings on your clients (some, which contain both, japan and chinese characters)
    ^/\x

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •