This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes JDBC and the fly likes Default encoding used while saving a varchar2(char) to a varchar2(byte) field. Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Databases » JDBC
Bookmark "Default encoding used while saving a varchar2(char) to a varchar2(byte) field." Watch "Default encoding used while saving a varchar2(char) to a varchar2(byte) field." New topic
Author

Default encoding used while saving a varchar2(char) to a varchar2(byte) field.

Pushker Chaubey
Ranch Hand

Joined: Dec 06, 2006
Posts: 53
Hi,

Here is the situation.

1) We are using oracle DB. we have a field in one of the table and that is having the type varchar2(500 bytes). please note that it is 500 bytes not characters.

2) From my java code I am using pstmt.setString() to set a value in this field.


- I want to know encoding will be used here to change characters to bytes -- the one configured in DB, Or the one which is default for the JVM. Or if there exists any default encoding setting at jdbc driver level.

- Also please let me know how to figure out default encoding used in this case. Any code snippet which will get me the encoding being used here?


Thanks in advance!
Pushker Chaubey
Martin Vajsar
Sheriff

Joined: Aug 22, 2010
Posts: 3606
    
  60

The data will be stored using database character set. You can display this (and other national specific settings) with the following:

Look for the NLS_CHARACTERSET parameter. You should not need any specific privileges.

If you don't know what the database character set is, you may consider the NVARCHAR2 datatype. NVARCHAR2 is independent on the database character set.
Pushker Chaubey
Ranch Hand

Joined: Dec 06, 2006
Posts: 53
Thanks a lot for your response sir!
 
jQuery in Action, 2nd edition
 
subject: Default encoding used while saving a varchar2(char) to a varchar2(byte) field.
 
Similar Threads
What every developer should know about character encoding
Fit or not fit (Oracle varchar2 problem)
Japanese character set
NX: URLyBird 1.2.1 - Character encoding
differents between PrintWriter and PrintStream