dbTalk Databases Forums  

Re: Oracle Clob and characters from 0x80-0xa0 (128-160)

comp.databases.oracle.misc comp.databases.oracle.misc


Discuss Re: Oracle Clob and characters from 0x80-0xa0 (128-160) in the comp.databases.oracle.misc forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
bung ho
 
Posts: n/a

Default Re: Oracle Clob and characters from 0x80-0xa0 (128-160) - 07-10-2003 , 10:20 PM






"Ilia" <nospam (AT) deathtospam (DOT) com> wrote

Quote:
I need to store all possible 256 characters in the DB using JDBC. All works
well when I use VARCHAR2 (I needed to set -Dfile.encoding=ISO-8859-1
parameter on the JVM). I can store values using resultSet.setString() and
retrieve using resultSet.getString().

The problem is that I need to store values longer than 4000 bytes. I
converted the column type to Clob and things broke:

I set the value using preparedStatement.setString() and it is stored
correctly in the database (I verified it using Toad). But when I use this
code to get the values, characters in the range 0x80-0xa0 come back as 253
instead:

Clob clob = resultSet.getClob(1);
String val = clob.getSubString(1, len);

I've tried all methods on Clob and CLOB but everything I tried screwes up
these characters. Please help!!

Thanks.
what platform is your client on (the machine that runs the java and
prints out your String val). are you sure this has to do with oracle,
since you say that it gets inserted correctly one way or the other?
in the following java snippet:

char c = 0x80;
System.out.println(c);

on windows, this code will print a ? when executed. since unicode
from 128-255 uses ISO-8859-1, and 128-159 are control characters in
ISO-8859-1, they will look busted in Cp1252 (windows default), which
don't have those control characters. what characters are you
expecting to see?

ps, are you sure it's 0x80-0xa0, and not 0x80-9f (i.e., 128-159)?


Reply With Quote
  #2  
Old   
Ilia
 
Posts: n/a

Default Re: Oracle Clob and characters from 0x80-0xa0 (128-160) - 07-11-2003 , 01:36 PM






Thank you for your interest, here is more info:

I run java program on Windows XP professional, JVM 1.3.1 with
a -Dfile.encoding=ISO-8859-1 JVM parameter. Oracle server is running under
Linux 7.3.

With this parameter, code

char c = 0x80
System.out.println(c);

prints out a Euro symbol.

You are right and the range is 0x80-0x9f.

OCI8 driver

NLS_DATABASE_PARAMETERS:

NLS_LANGUAGE AMERICAN
NLS_TERRITORY AMERICA
NLS_CURRENCY $
NLS_ISO_CURRENCY AMERICA
NLS_NUMERIC_CHARACTERS .,
NLS_CHARACTERSET WE8ISO8859P1
NLS_CALENDAR GREGORIAN
NLS_DATE_FORMAT DD-MON-RR
NLS_DATE_LANGUAGE AMERICAN
NLS_SORT BINARY
NLS_TIME_FORMAT HH.MI.SSXFF AM
NLS_TIMESTAMP_FORMAT DD-MON-RR HH.MI.SSXFF AM
NLS_TIME_TZ_FORMAT HH.MI.SSXFF AM TZH:TZM
NLS_TIMESTAMP_TZ_FORMAT DD-MON-RR HH.MI.SSXFF AM TZH:TZM
NLS_DUAL_CURRENCY $
NLS_COMP BINARY
NLS_NCHAR_CHARACTERSET WE8ISO8859P1
NLS_RDBMS_VERSION 8.1.7.0.1


"bung ho" <bung_ho (AT) hotmail (DOT) com> wrote

Quote:
"Ilia" <nospam (AT) deathtospam (DOT) com> wrote

I need to store all possible 256 characters in the DB using JDBC. All
works
well when I use VARCHAR2 (I needed to set -Dfile.encoding=ISO-8859-1
parameter on the JVM). I can store values using resultSet.setString()
and
retrieve using resultSet.getString().

The problem is that I need to store values longer than 4000 bytes. I
converted the column type to Clob and things broke:

I set the value using preparedStatement.setString() and it is stored
correctly in the database (I verified it using Toad). But when I use
this
code to get the values, characters in the range 0x80-0xa0 come back as
253
instead:

Clob clob = resultSet.getClob(1);
String val = clob.getSubString(1, len);

I've tried all methods on Clob and CLOB but everything I tried screwes
up
these characters. Please help!!

Thanks.

what platform is your client on (the machine that runs the java and
prints out your String val). are you sure this has to do with oracle,
since you say that it gets inserted correctly one way or the other?
in the following java snippet:

char c = 0x80;
System.out.println(c);

on windows, this code will print a ? when executed. since unicode
from 128-255 uses ISO-8859-1, and 128-159 are control characters in
ISO-8859-1, they will look busted in Cp1252 (windows default), which
don't have those control characters. what characters are you
expecting to see?

ps, are you sure it's 0x80-0xa0, and not 0x80-9f (i.e., 128-159)?



Reply With Quote
  #3  
Old   
bung ho
 
Posts: n/a

Default Re: Oracle Clob and characters from 0x80-0xa0 (128-160) - 07-14-2003 , 01:43 PM



woops. i don't know why it doesn't work for you then, it prints out
the euro for me fine (and i have almost the exact same setup as you).
maybe you should post your code (the CLOB insert as well as the
retrieval and print statements)

the fact that it's only 0x80-0x9f still makes me think it has
something to do with Cp1252 vs. ISO-8859-1.



"Ilia" <nospam (AT) deathtospam (DOT) com> wrote

Quote:
Thank you for your interest, here is more info:

I run java program on Windows XP professional, JVM 1.3.1 with
a -Dfile.encoding=ISO-8859-1 JVM parameter. Oracle server is running under
Linux 7.3.

With this parameter, code

char c = 0x80
System.out.println(c);

prints out a Euro symbol.

You are right and the range is 0x80-0x9f.


Reply With Quote
  #4  
Old   
Ilia
 
Posts: n/a

Default Re: Oracle Clob and characters from 0x80-0xa0 (128-160) - 07-14-2003 , 03:33 PM



int num = stmt.executeUpdate("delete from test");

// t.in contains 256 characters 0x00-0xff, -Dfile.encoding=ISO-8859-1
ensures that we use ISO-8859-1
String chars = Misc.getFileAsString("c:/tmp/t.in");

// table test contains two columns, first is varchar2 (256), second is a
CLOB
pstmt = dbconn.prepareStatement("insert into test values (?,?)");
pstmt.setString(1, chars.substring(128, 1));
pstmt.setString(2, chars.substring(128, 1));
pstmt.executeUpdate();
ResultSet rset = stmt.executeQuery("select * from test");

rset.next();
String newchars = rset.getString(1);
Clob newcharsclob = rset.getClob(2);
String newchars2 = newcharsclob.getSubString(1,
(int)newcharsclob.length());

close(dbconn);

System.out.println(newchars);
System.out.println(newchars2);

The first displays Euro, the second displays ?

When I look at the data with Toad, database contains Euro in both fields, so
I am guessing it's JDBC. I assume Toad uses some other database interface.


"bung ho" <bung_ho (AT) hotmail (DOT) com> wrote

Quote:
woops. i don't know why it doesn't work for you then, it prints out
the euro for me fine (and i have almost the exact same setup as you).
maybe you should post your code (the CLOB insert as well as the
retrieval and print statements)

the fact that it's only 0x80-0x9f still makes me think it has
something to do with Cp1252 vs. ISO-8859-1.



"Ilia" <nospam (AT) deathtospam (DOT) com> wrote

Thank you for your interest, here is more info:

I run java program on Windows XP professional, JVM 1.3.1 with
a -Dfile.encoding=ISO-8859-1 JVM parameter. Oracle server is running
under
Linux 7.3.

With this parameter, code

char c = 0x80
System.out.println(c);

prints out a Euro symbol.

You are right and the range is 0x80-0x9f.




Reply With Quote
  #5  
Old   
bung ho
 
Posts: n/a

Default Re: Oracle Clob and characters from 0x80-0xa0 (128-160) - 07-15-2003 , 11:42 AM



ok. i had forgotten one thing you mentioned earlier, which is that
you're using thick (oci8) driver. with the thin driver i couldn't
reproduce your problem but the thick driver does exhibit the "?"
behavior with the clob. it may have something to do with sqlnet nls
settings, i guess. can you use the thin driver?

"Ilia" <nospam (AT) deathtospam (DOT) com> wrote

Quote:
int num = stmt.executeUpdate("delete from test");

// t.in contains 256 characters 0x00-0xff, -Dfile.encoding=ISO-8859-1
ensures that we use ISO-8859-1
String chars = Misc.getFileAsString("c:/tmp/t.in");

// table test contains two columns, first is varchar2 (256), second is a
CLOB
pstmt = dbconn.prepareStatement("insert into test values (?,?)");
pstmt.setString(1, chars.substring(128, 1));
pstmt.setString(2, chars.substring(128, 1));
pstmt.executeUpdate();
ResultSet rset = stmt.executeQuery("select * from test");

rset.next();
String newchars = rset.getString(1);
Clob newcharsclob = rset.getClob(2);
String newchars2 = newcharsclob.getSubString(1,
(int)newcharsclob.length());

close(dbconn);

System.out.println(newchars);
System.out.println(newchars2);

The first displays Euro, the second displays ?

When I look at the data with Toad, database contains Euro in both fields, so
I am guessing it's JDBC. I assume Toad uses some other database interface.


"bung ho" <bung_ho (AT) hotmail (DOT) com> wrote in message
news:567a1b1.0307141043.4186097a (AT) posting (DOT) google.com...
woops. i don't know why it doesn't work for you then, it prints out
the euro for me fine (and i have almost the exact same setup as you).
maybe you should post your code (the CLOB insert as well as the
retrieval and print statements)

the fact that it's only 0x80-0x9f still makes me think it has
something to do with Cp1252 vs. ISO-8859-1.



"Ilia" <nospam (AT) deathtospam (DOT) com> wrote in message
news:<zsDPa.101359$8B.52664 (AT) twister (DOT) nyroc.rr.com>...
Thank you for your interest, here is more info:

I run java program on Windows XP professional, JVM 1.3.1 with
a -Dfile.encoding=ISO-8859-1 JVM parameter. Oracle server is running
under
Linux 7.3.

With this parameter, code

char c = 0x80
System.out.println(c);

prints out a Euro symbol.

You are right and the range is 0x80-0x9f.


Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.