Results 1 to 4 of 4
  1. #1
    hopfensp is offline Member
    Join Date
    Nov 2010
    Posts
    3
    Rep Power
    0

    Default jdbc and extended ascii

    This should be a simply problem for a JDBC expert. I have an field called cardholder_name defined as a varchar2(100 char) in an oracle table. One record in the table has an extended ascii character value (x89 - e with 2 dots above it) in the cardholder_name field. My code is straight forward.

    String s = resultSet.getString("cardholder_name");

    I know the data in the table is correct, I verified the value using a select statement in oracle sql developer, but somehow the x89 character turns into a x8F and xAE. I wrote a short program below to verify.

    byte[] bytes = resultSet.getBytes("cardholder_name");

    for (int x = 0; x < bytes.length; x++) {
    System.out.println(bytes[x]);
    }

    Any help would be appreciated, thanks.

  2. #2
    masijade is offline Senior Member
    Join Date
    Jun 2008
    Posts
    2,571
    Rep Power
    9

    Default

    What is your default character set on the machine running the code? That's where your problem lies, in all probability. The other possible problem is the NLS settings on the session to Oracle.

  3. #3
    hopfensp is offline Member
    Join Date
    Nov 2010
    Posts
    3
    Rep Power
    0

    Default

    Thanks for the reply, the default character set for both OS (red hat) and JVM is UTF-8.

    I did try to use the code below, all the correct int values for the characters display. It's just when I create a String object from the Reader or call the getString() method from the ResultSet object, I get 2 incorrect, garbled characters.

    Reader r = resultSet.getCharacterStream("card_holder_name");
    try {
    int c = r.read();
    while (c != -1) {
    System.out.println(c);
    c = r.read();
    }

  4. #4
    masijade is offline Senior Member
    Join Date
    Jun 2008
    Posts
    2,571
    Rep Power
    9

Similar Threads

  1. extended essay Survey
    By FF764 in forum New To Java
    Replies: 0
    Last Post: 08-18-2009, 08:44 AM
  2. Survey for the extended essay
    By FF764 in forum Advanced Java
    Replies: 0
    Last Post: 08-17-2009, 02:02 PM
  3. how to process the Extended ASCII character set in JNI?
    By mahendra.athneria in forum Advanced Java
    Replies: 1
    Last Post: 08-12-2009, 06:39 PM
  4. Returned type changes if class is extended. How?
    By Gelembjuk in forum New To Java
    Replies: 10
    Last Post: 10-31-2008, 11:18 AM
  5. writting extended ascii chars on socket........or Endianness Issue......??
    By sachinj13 in forum Threads and Synchronization
    Replies: 8
    Last Post: 09-23-2008, 02:20 PM

Posting Permissions

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