JDBC program is inserting ¿ in NVARCHAR2 column.

I have a 10.2.0.1 database on a windows XP machine.
The value of NLS_CHARACTERSET is WE8MSWIN1252 and the value of NLS_NCHAR_CHARACTERSET     is AL16UTF16.
I have a table with a NVARCHAR2 column. I am using JDBC thin driver to connect to the database. When I am to inserting a japanese character to this column, the value that is getting inserted is ¿ (inverted question mark) instead of the actual Japanese character. Following is the code snippet of my Java program
Class.forName("oracle.jdbc.OracleDriver");
props.put("user", "bcan");
props.put("password","bcan2226");
url = "jdbc:oracle:thin:@myserver:1521:eng";
Connection conn = DriverManager.getConnection(url, props);
String value = "abcdefghi\u7c73"; //\u7c73 is the japanese character
String sql = "insert into I18N VALUES ('" + value + "')";
Statement stmt = conn.createStatement();
stmt.executeUpdate(sql);
Can you please let me know why is ¿ getting inserted instead of the japanese character I am trying to insert?
BTW I noticed that if I use PreparedStatement like the following then the proper character gets inserted.
Class.forName("oracle.jdbc.OracleDriver");
props.put("user", "bcan");
props.put("password","bcan2226");
props.put("oracle.jdbc.defaultNChar","true");
url = "jdbc:oracle:thin:@myserver:1521:eng";
Connection conn = DriverManager.getConnection(url, props);
String value ="abcdefghi\u7c73";
String sql = "insert into I18N VALUES (?)";
PreparedStatement stmt = conn.prepareStatement(sql);
stmt.setString(1,value);
stmt.executeUpdate();
Thanks
Sudipta

I do not think that you are hitting a "bug". Instead what you are seeing is expected behaviour since sql and literals (e.g. your string) are processed in the database character set unless you specify otherwise (e.g. explicit bind).
Go through docs per links in my previous post.
For the bug referenced, it seemed to be fixed according to jdbc driver Readme of 10.2.0.4.

Similar Messages

  • Insert into NVARCHAR2 columns(ORA_01461, ORA-01026)

    Hi,
    Oracle8i Client 8.1.5 (OCI8)
    Oracle9i Client 9.0.1 (OCI9)
    Oracle8i/9i DB
    I want to insert strings into a table with two NVARCHAR2 columns with OCI.
    NLS_NCHAR_CHARACTERSET is UTF8 (DB). The provided String is encoded in Windows-1252.
    The supplied buffers in the OCIBindByPos have a size of 200bytes each.
    ->With OCI8 I'm getting the message:
    "ORA-01026 multiple buffers of size > 4000 in the bind list"
    If only one NVARCHAR2 column is involved (or if I use normal
    VARCHAR2 instead) it works fine.
    ->With OCI9 I get the message:
    "ORA-01461 can bind a LONG value only for insert into a LONG column"
    But only, if I set the OCI_ATTR_MAXDATA_SIZE attribute.
    If I do not set the OCI_ATTR_MAXDATA_SIZE attribute, it works, but if
    I supply a buffer bigger than 1333 bytes in the OCIBindByPos for the second
    NVARCHAR2 column, then ORA_01461 happens. The buffer for the first NVARCHAR2
    column can be set to a higher values
    ->The same behaviour occurs with NCHAR, NCLOB (->national character types)
    These are the main steps:
    OCIBindByPos((OCIStmt *) pStmtInsert, (OCIBind **) &pBind,
    (OCIError *) pError, (ub4) i, (dvoid *)pData,
    (sb4) bufferSize, //200bytes
    (ub2) dataTypeSQLT, //SQLT_STR
    (dvoid *) pIndicator, (ub2 *) 0, (ub2 *) 0, (ub4) 0,
              (ub4 *) 0, (ub4) OCI_DEFAULT);
    OCIAttrSet((dvoid *) pBind, OCI_HTYPE_BIND,
    &Frm, //SQLCS_NCHAR
         0, OCI_ATTR_CHARSET_FORM, (OCIError *) pError);
    OCIAttrSet((dvoid *) pBind, OCI_HTYPE_BIND,
    (dvoid *) &charSet, //WE8MSWIN1252
         0, OCI_ATTR_CHARSET_ID, (OCIError *) pError);
    OCIAttrSet((dvoid *) pBind, OCI_HTYPE_BIND,
    (dvoid *) &maxDataSize, //->size of the column in bytes
    0, OCI_ATTR_MAXDATA_SIZE, (OCIError *) pError);
    OCIStmtExecute((OCISvcCtx *) pServiceContext, (OCIStmt *) pStmtInsert,(OCIError *) pError,
    (ub4) 1, (ub4) 0, (OCISnapshot *) 0, (OCISnapshot *) 0,
    OCI_COMMIT_ON_SUCCESS);
    Any ideas?
    Thanks,
    Axel

    I found this link referring to a similar problem that was apparently fixed in version 10.2.0.4 of the server: ORA-01461: can bind a LONG value only for insert into a LONG column Should I try to upgrade the server and see if that fixes things?

  • Need to insert into NVARCHAR2 column in a database table

    I need to insert into a table with column type NVARCHAR2(2000) in java.
    Cant use normal setString on that column. How can I do this using PreparedStatement in Java?

    The scenario is:
    I have to read a CSV file which contains a column in Urdu language, and show it on the JTable first.
    Then I have to import the JTable contents into a database table.
    Database Table structure is:
    CREATE TABLE IMPORT_TMP (
    ctype          VARCHAR2(3),
    urdu_name  NVARCHAR2(2000)
    );My java code which inserts into the database table is:
                    Vector dataVector = tableModel.getDataVector();
                    rowVector = (Vector) dataVector.get(row);
                  cType = "";
                    if (rowVector.get(INDEX_BANK) != null) {
                        cType = rowVector.get(INDEX_CTYPE).toString();
                    urduName = "";
                    if (rowVector.get(INDEX_URDU_NAME) != null) {
                        urduName = rowVector.get(INDEX_URDU_NAME).toString();
                    statementInsert.setString(1, cType);
                    statementInsert.setString(2, urduName);I also applied Renderer on the table column, my renderer class is:
    public class LangFontRenderer extends JLabel implements TableCellRenderer {
        private Font customFont;
        public LangFontRenderer(Font font) {
            super();
            customFont = font;
            System.out.println("font = " + font.getFontName());
            this.setFont(font);
        @Override
        public Component getTableCellRendererComponent(JTable table,
                Object value, boolean isSelected, boolean hasFocus, int row, int column) {
            if (value != null) {
                if (value instanceof String) {
                    setText((String) value);
                    return this;
            return this;
        @Override
        public Font getFont() {
            return customFont;
        // overriding other methods for performance reasons only
        @Override
        public void invalidate() {
        @Override
        public boolean isOpaque() {
            return true;
        @Override
        public void repaint() {
        @Override
        public void revalidate() {
        @Override
        public void validate() {
    }I applied the renderer on the column as:
            TableColumn col = IATable.getColumnModel().getColumn(INDEX_URDU_NAME);
            LangFontRenderer langRenderer = new LangFontRenderer(new java.awt.Font("Urdu Naskh Asiatype", 0, 11));
            col.setCellRenderer(langRenderer);It does not give any error but when i query on the database table it does not show the column data in Urdu language.
    Also it does not show the correct value on JTable column, some un-identified symbols.
    Furthermore when I open the CSV file in notepad, it shows the correct language in that column, as I have installed the Urdu language and font on my system.

  • Help! can't store ja16sjis to nvarchar2 column.

    hi:
    I am using Oracle8.1.7.
    And NLS_CHARACTERSET=UTF8 ,
    NLS_NCHAR_CHARACTERSET=JA16SJIS ,
    I can store sjis code into varchar2 column,
    but when store into nvarchar2 column, all the code
    are converted into USASCII7. many '?' there.
    I use
    insert into test values('xxx')
    to insert into varchar2 column.
    and use
    insert into test values(N'xxx')
    to insert into nvarchar2 column.
    where's the problem?
    NLS_LANG=japanese_japan.ja16sjis
    NLS_NCHAR=japanese_japan.ja16sjis.
    Thanks inadvance.
    null

    Thanks for the suggestion.....
    But I am confused about what you mean by "starting over and using a new icon".
    BTW, I had not done anything w/ the icon in the first place.
    Still confused

  • What is wrong with my tiny jdbc program? Help!!!

    Hi,
    Would anyone diagnose the problem of my simple jdbc program?
    The situation is :
    a) local machine oracle thin driver connection; "lsnrctl" is running.
    b) I can query the statement "select id from gameUser" from SQLPLUS logged in as "scott", with desirable result.
    c) There are two code lines commented out in the code, if I uncomment them and instead comment out their counterparts and run the program, the "rset" would contain the result I want. But if I run the program unchanged, the output is only "hi".
    d) If I change the query statement to a wrong column name or a wrong table name, there would be a sql exception. So I surmise that the connection with the database is successful. But how come there is no query result???
    The follow is my coding.
    import java.sql.*;
    class dbAccess {
    public static void main (String args []) throws SQLException
    DriverManager.registerDriver (new oracle.jdbc.driver.OracleDriver());
    try{
    Connection conn = DriverManager.getConnection
    ("jdbc:oracle:thin:orcl", "scott", "tiger");
    // ("jdbc:oracle:thin:orcl", "system", "manager");
    Statement stmt = conn.createStatement();
    ResultSet rset = stmt.executeQuery("select ID from scott.gameUser");
    // ResultSet rset = stmt.executeQuery("select BANNER from SYS.V_$VERSION");
    while (rset.next())
    System.out.println (rset.getString(1)); stmt.close();
    System.out.println("hi");
    }catch (Exception e)
    System.out.println(e.toString());
    Thanks for help!

    "local machine oracle thin driver connection;" means that my jdbc application uses Oracle thin driver to connect to a Oracle database. The database and the application are both on the same local machine.
    "lsnrctl" is the command line program running to accept incomming request to connect to the database, it listens on the default 1521 port.
    I inserted two rows into the table and I could query these two rows in SQLPLUS.
    And I tried "select ID from gameUser", "select id from scott.gameUser" and various combination, it just won't retrieve the rows I inserted in the table.

  • Cannot Store Greek Characters in NVARCHAR2 columns

    Can someone please help.
    I have a table TEST with one column A of type NVARCHAR2(20) and when I try to insert the greek character Ω(Omega) - it gets stored as O instead.
    I am inserting using SQL Developer using the 'N' prefix and my environment is as follows:
    Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - 64bit Production
    NLS_CHARACTERSET = WE8MSWIN1252
    NLS_NCHAR_CHARACTERSET = AL16UTF16
    NLS_LANG setting on client side is ENGLISH_UNITED KINGDOM.WE8MSWIN1252.
    Why can I not insert greek characters with the above setup and what do I need to do/change in order to be able to insert greek characters in a database using the national characterset for storing unicode data ?

    Result of running SELECT a, dump(a) FROM TEST after insert an 'O' and an 'Ω' is as follows:
    A DUMP(A)
    O     Typ=1 Len=2: 0,79
    O     Typ=1 Len=2: 0,79
    I added a VARCHAR column, column B, there is no difference in what is getting stored in the NVARCHAR column when inserting 'Ω', result is below:
    INSERT INTO TEST (A, B)
    VALUES(N'Ω', 'Ω');
    SELECT a, dump(a, 1016), b, dump(b, 1016) FROM TEST;
    A DUMP(A, 1016) B DUMP(B, 1016)
    O     Typ=1 Len=2 CharacterSet=AL16UTF16: 0,4f     O     Typ=1 Len=1 CharacterSet=WE8MSWIN1252: 4f
    I'm I missing something here, since my understanding is that NVARCHAR2 columns should be able to store Unicode data ?

  • OC4J 904 and Unicode(AL16UTF16) in NVARCHAR2 column

    I have:
    OC4J 904 standalone runs on Windows2000 AdvancedServer.
    Oracle 9i
    JDBC thin driver shipped with OC4J
    NLS_NCHAR_CHARSET = AL16UTF16
    (NLS_CHARACTERSET = VN8VN3)
    I have a table with a NVARCHAR2 column. I created a CMP EJB from the table but I can't use the EJB to retreive data from Database. I was success in using Oracle JDBC connection to connect manually to database and save/retreive Unicode data.
    I read somewhere that EJB use thin driver, so the getter/setter of CMP-Fields should work normally.
    I think that may be the problems is the function OraclePreparedStatement.setFormOfUse(1,OraclePreparedStatement.FORM_NCHAR);
    was not called in the EJB Contenner or things like that - so it's a bug of OC4J, right?.
    This is the Exception I received on the browser.
    javax.ejb.NoSuchObjectLocalException: ? ?ÂY CÓ CH? HOA CÓ D?U!!!!!
         at TestLocal_EntityBeanWrapper0.reActivateNew(TestLocal_EntityBeanWrapper0.java:1668)
         at TestLocal_EntityBeanWrapper0.reActivateNewLocal(TestLocal_EntityBeanWrapper0.java:1636)
         at TestLocal_EntityBeanWrapper0.getUnicode(TestLocal_EntityBeanWrapper0.java:108)
         at test.showparam._jspService(_showparam.java:100)
         [SRC:/test/showparam.jsp:65]
         at com.orionserver[Oracle9iAS (9.0.4.0.0) Containers for J2EE].http.OrionHttpJspPage.service(OrionHttpJspPage.java:56)
         at oracle.jsp.runtimev2.JspPageTable.service(JspPageTable.java:348)
         at oracle.jsp.runtimev2.JspServlet.internalService(JspServlet.java:498)
         at oracle.jsp.runtimev2.JspServlet.service(JspServlet.java:402)
         at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
         at com.evermind[Oracle9iAS (9.0.4.0.0) Containers for J2EE].server.http.ResourceFilterChain.doFilter(ResourceFilterChain.java:65)
         at oracle.security.jazn.oc4j.JAZNFilter.doFilter(JAZNFilter.java:293)
         at com.evermind[Oracle9iAS (9.0.4.0.0) Containers for J2EE].server.http.ServletRequestDispatcher.invoke(ServletRequestDispatcher.java:602)
         at com.evermind[Oracle9iAS (9.0.4.0.0) Containers for J2EE].server.http.ServletRequestDispatcher.forwardInternal(ServletRequestDispatcher.java:308)
         at com.evermind[Oracle9iAS (9.0.4.0.0) Containers for J2EE].server.http.HttpRequestHandler.processRequest(HttpRequestHandler.java:779)
         at com.evermind[Oracle9iAS (9.0.4.0.0) Containers for J2EE].server.http.HttpRequestHandler.run(HttpRequestHandler.java:264)
         at com.evermind[Oracle9iAS (9.0.4.0.0) Containers for J2EE].server.http.HttpRequestHandler.run(HttpRequestHandler.java:107)
         at com.evermind[Oracle9iAS (9.0.4.0.0) Containers for J2EE].util.ReleasableResourcePooledExecutor$MyWorker.run(ReleasableResourcePooledExecutor.java:186)
         at java.lang.Thread.run(Thread.java:536)
    Can anybody help or give me some information or workaround?
    Thank you very much.

    Hi Nghia,
    Can anybody help or give me some information or
    workaround? I suggest using BMP and a non-emulated data source. More details are available in the documentation which can be downloaded from here:
    http://technet.oracle.com/tech/java/oc4j/904/documentation_preview.html
    Good Luck,
    Avi.

  • ORA-1461 with multiple NVARCHAR2 columns

    Hi,
    I use version 10.2.0.1 version of ojdbc with an Oracle9i database and get ORA-1461 (can bind a LONG value only for insert into a LONG column) when updating multiple NVARCHAR2 columns in the same table.
    What is strange is:
    if I set column1=value1 and column2 null it works
    if I set column2=value2 and column1 null it works
    But if i set column1=value1 AND column2=value2 I have this exception.
    I assume that because using UTF8 I can have an exception for one column if less than 4000 because of nb bytes used by one character but can't understand why different columns sizes interact...
    Database parameters :
    NLS_CHARACTERSET AL32UTF8
    NLS_NCHAR_CHARACTERSET     UTF8
    NLS_LENGTH_SEMANTICS     BYTE
    NLS_NCHAR_CONV_EXCP     FALSE (don't know if usefull)
    Can anyone tell me out to make it work ?
    I tried with driver 10.2.0.3 and have the same issue.
    Thanks for your help.
    Message was edited by:
    user610168

    Hi,
    I use version 10.2.0.1 version of ojdbc with an Oracle9i database and get ORA-1461 (can bind a LONG value only for insert into a LONG column) when updating multiple NVARCHAR2 columns in the same table.
    What is strange is:
    if I set column1=value1 and column2 null it works
    if I set column2=value2 and column1 null it works
    But if i set column1=value1 AND column2=value2 I have this exception.
    I assume that because using UTF8 I can have an exception for one column if less than 4000 because of nb bytes used by one character but can't understand why different columns sizes interact...
    Database parameters :
    NLS_CHARACTERSET AL32UTF8
    NLS_NCHAR_CHARACTERSET     UTF8
    NLS_LENGTH_SEMANTICS     BYTE
    NLS_NCHAR_CONV_EXCP     FALSE (don't know if usefull)
    Can anyone tell me out to make it work ?
    I tried with driver 10.2.0.3 and have the same issue.
    Thanks for your help.
    Message was edited by:
    user610168

  • How to start JDBC program from web.

    Okay I have researched this alot on how you are suppose to connect to a database using JSP and all the example just show how to print the entire database. What I need to do is take a JDBC program I have written and make it run on a web page. How can I call the program to run on a web page. The JDBC program will search,update,add information into a database but how do I get the JDBC program run on a web server. I am a newbie in JSP.

    Then could someone tell me what is the point in learning JDBC if you can't use it for web applications? Could someone then tell me which to learn in order for me to implement using my database on the web. Should I learn how to do it as a servlet or in JSP. Which is going to require less time to learn. I am kinda in a time crunch on this one. I would really like to learn both and I will probably go back and do that but I don't have time to learn both so any advice would be helpful. Thank you for you time.

  • In the Pages Program template on the 4 column page a text is wrapped around a violinist photo How do I prepare the photo for a similar result

    In the Pages Program template on the 4 column page a text is wrapped around a violinist.
    How do I have to prepare the photo to have a similar result.
    Thanks

    You need to have an image with a more or less even background or at least contrasting to the main part.
    Menu > Format > Instant Alpha > run the cursor over the parts you want to eliminate
    With the image selected > Inspector > Wrap > check Image causes wrap > click on 2nd icon > Text Fit > 2nd icon
    Play with Extra Space and Alpha to get what you want.
    Peter

  • How to insert filename as column in external table.

    I have an external table that is made up by number of different files. I would like to add a new column in the table to store the actual external filename. How can this be done?
    thanks in advanced

    That's going to be a problem, then. The ISO 8859-1 character set doesn't support that character, so you cannot store a ™ in a CHAR or VARCHAR2 column in your database.
    Potentially, you could use an NCHAR or NVARCHAR2 column, depending on your national character set. Using the national character set, though, can cause other problems, particularly for front-end applications that may not fully support those data types.
    You could also potentially change your existing character set to something that does support that character, but that may be a rather involved sort of change.
    Justin

  • Use of JTA API in JDBC programs.

    Hi,
    Where we can use JTA API in JDBC programs. what is the significance of UserTransaction interface in JDBC programs. I heard that when we are using two databases in same program then we use this JTA API. Can't we do this by using,
    connection.setAutoCommint(false);
    // code to work with two database
    connection.commit();
    does it wont work.
    Please suggest me.
    Thanks
    Satish

    I heard that when we are using two
    databases in same program then we use this JTA API.
    Can't we do this by using,
    connection.setAutoCommint(false);
    // code to work with two database
    connection.commit();This will work if there are no errors or crashes, but it can seriously fail otherwise.
    To find out more: you can download our JTA from http://www.atomikos.com and go through the JTA user guide. It includes the answer to your question.
    Alternatively, feel free to check our transactions community forum on http://www.atomikos-support.com/forums (which we check more often than this one).
    Best,
    Guy

  • Can't see my tables from a JDBC program

    Hi there,
    I have a JDBC program to connect to an Oracle 9i database. The problem is that I can't see the tables I create if I do something like "SELECT * FROM TAB" from a JDBC program and hence can't use them.
    If I do the same statement from SQL * PLUS, I get the the full list of my tables including the ones I created. If i do that from JDBCTest.java, I don't get to see them. I do commit my statments and have tried committing from the Java program and from the SQL Plus after creating the tables....
    Just to make sure I have checked myself, I am pretty sure that I am connecting with the same ID/Password in which I created my tables. I have also used schema.table to no avail... I have used scott/tiger and system/manager
    If i try st.executeUpdate() for example, I get the error : java.sql.sqlException: ORA-00942: table or view does not exist...
    Any help would be greatly appreciated
    Thanx :)
    Nav

    Hi MOD,
    hmmm. Sorry I am not an Oracle geek, but I am under system/manager and I created them all in there. I thought permissions are granted automatically. I tried to grant permissions to myself but had an error that I can't update them myself...
    Can you plz elaborate on how to set permissions cuz actually i installed the database (password still default) and I am not sure if there is a dba other than system/manager who could grant me permissions...
    It works on my home machine with the exact same version of Oracle and Java though and the same users and password :s
    Any other thoughts
    Thanx
    NAV

  • SQL*Loader-930: Error parsing insert statement for column

    we upload data on daily basis in application throug apps user and these table are invloved
    1. DEV_RA_INTERFACE_LINES_ALL(owner is a apps)
    2.RA_INTERFACE_LINES_ALL(owner is a AR)
    we do steps
    1 delete record from DEV_RA_INTERFACE_LINES_ALL table
    2 delete record from      RA_INTERFACE_LINES_ALL table
    3 load data using sql loader with apps user
    4 insert in RA_INTERFACE_LINES_ALL table
    we want to change user i mean these step do dataupload user not apps
    we give the proper rights to dataupload like select,delete and insert rights on these table to dataupload user but when i going to load data throug sql loader we receive error
    SQL*Loader-930: Error parsing insert statement for column APPS.DEV_RA_INTERFACE_
    LINES_ALL.ORIG_SYSTEM_BILL_ADDRESS_ID.
    ORA-00904: "F_ORIG_SYSTEM_BILL_ADDR_REF": invalid identifier
    and if i insert data through apps then done.

    make sure that u have no speces left
    between lines.
    give the path of control file path correctly.

  • Need help in writing NVARCHAR2 column to an excel sheet

    Hi All,
    I have a NVARCHAR2 column in my table. I want to store the data present in the column into an excel file. When i write the data to an excel file the data is getting converted to some other form. It's not in human readable form.
    Language is not fixed for the column.
    I need help in storing the NVARCHAR2 data into an excel file without any implicit conversion done by the oracle.
    Please help.
    Thanks,
    Girish G
    Edited by: Girish G on Jul 14, 2011 2:02 AM

    Export data to BLOB (csv)

Maybe you are looking for