URGENT !! ClassCastException in CLOB.createTemporary  Feb

I get oracle Connection from websphere datasource.
The connection object is of type com.ibm.ejs.cm.proxy.OracleConnectionProxy
This is not compatible with CLOB.createTemporary
The code I execute is:
CLOB.createTemporary(conn, true, CLOB.DURATION_SESSION); It gives me ClassCastException.
I saw these kind of problems but have not seen any solution!
Any help is appreciated.
Thanks
Nadeem

That is not the issue. The problem is that,
CLOB.createTemporary requires OracleConnection instead of just java.sql.Connection.
When we are in a application server, the connection object cannot be OracleConnection as the DataSouce retrieved from JNDI cannot return OracleConnection. The websphere data source wraps the Connection Pool and physical connection to control the Database Transactions.
Currently, the only way out 3 step process. First step will write empty_clob
for example insert/update (someClob) values (empty_clob)
read the same record
retrive empty_clob pointer
Update values
Commit changes
This is definitely not a scalable solution to the problem.
Hope someone has already done something about it and have a solution for this problem?
Nadeem

Similar Messages

  • URGENT !! ClassCastException in CLOB.createTemporary

    Oracle 9iAS and CLOB. ClassCastException.
    I get oracle Connection from websphere datasource.
    The connection object is of type com.ibm.ejs.cm.proxy.OracleConnectionProxy
    This is not compatible with CLOB.createTemporary
    The code I execute is:
    CLOB.createTemporary(conn, true, CLOB.DURATION_SESSION); It gives me ClassCastException.
    I saw these kind of problems but have not seen any solution!
    Any help is appreciated.
    Thanks
    Nadeem

    That is not the issue. The problem is that,
    CLOB.createTemporary requires OracleConnection instead of just java.sql.Connection.
    When we are in a application server, the connection object cannot be OracleConnection as the DataSouce retrieved from JNDI cannot return OracleConnection. The websphere data source wraps the Connection Pool and physical connection to control the Database Transactions.
    Currently, the only way out 3 step process. First step will write empty_clob
    for example insert/update (someClob) values (empty_clob)
    read the same record
    retrive empty_clob pointer
    Update values
    Commit changes
    This is definitely not a scalable solution to the problem.
    Hope someone has already done something about it and have a solution for this problem?
    Nadeem

  • Anyone get CLOB.createTemporary to work in WebLogic w/ Ora 9.0.1?

    I've got code that works in java for temporary CLOB in Oracle 9.0.1. It works using JDBC Client API or Oracle connection pooling. But when I deploy to WebLogic App Server, I get
    "java.lang.reflect.InvocationTargetException null" on the statement:
    myClob = CLOB.createTemporary(conn, false, CLOB.DURATION_SESSION);
    I read that temporary clob was an Oracle extension. That would lead one to believe that WebLogic may not support it. And I tried tweeking classpath/path to use Oracle's jars first, etc. I've also tried different ways of connecting: JDBC Client, straight RMI, and JNDI lookups, trying to get around "WebLogic"... Is this a losing battle and do I have to modifiy my code to use the EMPTY_CLOB() functions, or has someone gotten this to work? THANKS!

    I've talked with BEA on this issue. They say that the CLOB.createTemporary() method signature indicates that it takes a
    generic JDBC object, but it in fact takes an Oracle-specific object. They say "Oracle is lying to us" and say that
    as a result, my code will not work if using a WebLogic Connection Pool. I realize the risks of using vendor-specific
    extension methods, but I would think that if I configure the WL app server to use the oracle classes12.zip and put it in
    front of CLASSPATH, etc. that this would work. It does not, with the BEA reason stated above. I really like this
    CLOB.createTemporary method and refuse to change my code. Any words of wisdom, especially from an
    Oracle insider? Thanks!
    I've got code that works in java for temporary CLOB in Oracle 9.0.1. It works using JDBC Client API or Oracle connection pooling. But when I deploy to WebLogic App Server, I get
    "java.lang.reflect.InvocationTargetException null" on the statement:
    myClob = CLOB.createTemporary(conn, false, CLOB.DURATION_SESSION);
    I read that temporary clob was an Oracle extension. That would lead one to believe that WebLogic may not support it. And I tried tweeking classpath/path to use Oracle's jars first, etc. I've also tried different ways of connecting: JDBC Client, straight RMI, and JNDI lookups, trying to get around "WebLogic"... Is this a losing battle and do I have to modifiy my code to use the EMPTY_CLOB() functions, or has someone gotten this to work? THANKS!

  • NullPointer when calling CLOB.createTemporary()

    Hi all,
    I am trying to insert an xml of size more than 4k into an xml type table. Given below is the code i am using to create the CLOB to insert the same.
    I am getting a NullPointerException while creating the CLOB.
    Please help me out here!!
    CODE
    private CLOB getCLOB(String xmlData, Connection conn) throws SQLException {
              CLOB tempClob = null;
              try {
                   System.out.println("xml : ### : " + xmlData);
                   // If the temporary CLOB has not yet been created, create new
                   tempClob = CLOB.createTemporary(conn, true, CLOB.DURATION_CALL);
                   // Open the temporary CLOB in readwrite mode to enable writing
                   tempClob.open(CLOB.MODE_READWRITE);
                   // Get the output stream to write
                   Writer tempClobWriter = tempClob.getCharacterOutputStream();
                   // Write the data into the temporary CLOB
                   tempClobWriter.write(xmlData);
                   // Flush and close the stream
                   tempClobWriter.flush();
                   tempClobWriter.close();
                   // Close the temporary CLOB
                   tempClob.close();
              } catch (SQLException sqlexp) {
                   // tempClob.freeTemporary();
                   sqlexp.printStackTrace();
              } catch (Exception exp) {
                   // tempClob.freeTemporary();
                   exp.printStackTrace();
              return tempClob;
    STACK TRACE
    java.lang.NullPointerException
         at oracle.sql.LobPlsqlUtil.plsql_createTemporaryLob(LobPlsqlUtil.java:1354)
         at oracle.jdbc.dbaccess.DBAccess.createTemporaryLob(DBAccess.java:997)
         at oracle.sql.LobDBAccessImpl.createTemporaryClob(LobDBAccessImpl.java:240)
         at oracle.sql.CLOB.createTemporary(CLOB.java:527)
         at com.cx.hcm.ams.slatingms.impl.dao.SlatingDAOImpl.getCLOB(SlatingDAOImpl.java:1359)
         at com.cx.hcm.ams.slatingms.impl.dao.SlatingDAOImpl.insertXML(SlatingDAOImpl.java:1327)
         at com.cx.hcm.ams.slatingms.impl.ejb.SlatingMgmtSessionBean.insertXML(SlatingMgmtSessionBean.java:855)
         at SlatingMgmtRemote_StatelessSessionBeanWrapper16.insertXML(SlatingMgmtRemote_StatelessSessionBeanWrapper16.java:3782)
         at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
         at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
         at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
         at java.lang.reflect.Method.invoke(Method.java:324)
         at com.evermind.server.rmi.RMICallHandler.run(RMICallHandler.java:119)
         at com.evermind.server.rmi.RMICallHandler.run(RMICallHandler.java:48)
         at EDU.oswego.cs.dl.util.concurrent.PooledExecutor$Worker.run(PooledExecutor.java:803)
         at java.lang.Thread.run(Thread.java:536)

    Hi all,
    I am trying to insert an xml of size more than 4k into an xml type table. Given below is the code i am using to create the CLOB to insert the same.
    I am getting a NullPointerException while creating the CLOB.
    Please help me out here!!
    CODE
    private CLOB getCLOB(String xmlData, Connection conn) throws SQLException {
              CLOB tempClob = null;
              try {
                   System.out.println("xml : ### : " + xmlData);
                   // If the temporary CLOB has not yet been created, create new
                   tempClob = CLOB.createTemporary(conn, true, CLOB.DURATION_CALL);
                   // Open the temporary CLOB in readwrite mode to enable writing
                   tempClob.open(CLOB.MODE_READWRITE);
                   // Get the output stream to write
                   Writer tempClobWriter = tempClob.getCharacterOutputStream();
                   // Write the data into the temporary CLOB
                   tempClobWriter.write(xmlData);
                   // Flush and close the stream
                   tempClobWriter.flush();
                   tempClobWriter.close();
                   // Close the temporary CLOB
                   tempClob.close();
              } catch (SQLException sqlexp) {
                   // tempClob.freeTemporary();
                   sqlexp.printStackTrace();
              } catch (Exception exp) {
                   // tempClob.freeTemporary();
                   exp.printStackTrace();
              return tempClob;
    STACK TRACE
    java.lang.NullPointerException
         at oracle.sql.LobPlsqlUtil.plsql_createTemporaryLob(LobPlsqlUtil.java:1354)
         at oracle.jdbc.dbaccess.DBAccess.createTemporaryLob(DBAccess.java:997)
         at oracle.sql.LobDBAccessImpl.createTemporaryClob(LobDBAccessImpl.java:240)
         at oracle.sql.CLOB.createTemporary(CLOB.java:527)
         at com.cx.hcm.ams.slatingms.impl.dao.SlatingDAOImpl.getCLOB(SlatingDAOImpl.java:1359)
         at com.cx.hcm.ams.slatingms.impl.dao.SlatingDAOImpl.insertXML(SlatingDAOImpl.java:1327)
         at com.cx.hcm.ams.slatingms.impl.ejb.SlatingMgmtSessionBean.insertXML(SlatingMgmtSessionBean.java:855)
         at SlatingMgmtRemote_StatelessSessionBeanWrapper16.insertXML(SlatingMgmtRemote_StatelessSessionBeanWrapper16.java:3782)
         at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
         at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
         at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
         at java.lang.reflect.Method.invoke(Method.java:324)
         at com.evermind.server.rmi.RMICallHandler.run(RMICallHandler.java:119)
         at com.evermind.server.rmi.RMICallHandler.run(RMICallHandler.java:48)
         at EDU.oswego.cs.dl.util.concurrent.PooledExecutor$Worker.run(PooledExecutor.java:803)
         at java.lang.Thread.run(Thread.java:536)

  • CLOB.createTemporary throws SQL Exception

    The following statement:
    tempClob = CLOB.createTemporary(fDataConn, true, CLOB.DURATION_SESSION);
    causes the following exception in jdev 10.1.2.0.0 Build 1811, but did not cause this exception in the jdev version in download jdev9052.zip
    05/09/07 17:59:08 java.sql.SQLException: Invalid argument(s) in call
    05/09/07 17:59:08      at oracle.jdbc.dbaccess.DBError.throwSqlException(DBError.java:189)
    05/09/07 17:59:08      at oracle.jdbc.dbaccess.DBError.throwSqlException(DBError.java:231)
    05/09/07 17:59:08      at oracle.jdbc.dbaccess.DBError.throwSqlException(DBError.java:294)
    05/09/07 17:59:08      at oracle.sql.CLOB.createTemporary(CLOB.java:527)
    The only thing thats changable in the Connection object.
    I've verified that the Connection object has the correct info inside.
    I create the Connection object via a context lookup with JNDI.
    Does createTemporary care how I create the Connection object?
    Thanks
    Jim

    The following statement:
    tempClob = CLOB.createTemporary(fDataConn, true, CLOB.DURATION_SESSION);
    causes the following exception in jdev 10.1.2.0.0 Build 1811, but did not cause this exception in the jdev version in download jdev9052.zip
    05/09/07 17:59:08 java.sql.SQLException: Invalid argument(s) in call
    05/09/07 17:59:08      at oracle.jdbc.dbaccess.DBError.throwSqlException(DBError.java:189)
    05/09/07 17:59:08      at oracle.jdbc.dbaccess.DBError.throwSqlException(DBError.java:231)
    05/09/07 17:59:08      at oracle.jdbc.dbaccess.DBError.throwSqlException(DBError.java:294)
    05/09/07 17:59:08      at oracle.sql.CLOB.createTemporary(CLOB.java:527)
    The only thing thats changable in the Connection object.
    I've verified that the Connection object has the correct info inside.
    I create the Connection object via a context lookup with JNDI.
    Does createTemporary care how I create the Connection object?
    Thanks
    Jim

  • CLOB.createTemporary gives Nullpointer Exception

    Hello,
    I'm trying to create a temporary clob in my java code, but when I run the program I get the following exception.
    java.lang.NullPointerException
         at oracle.sql.LobPlsqlUtil.plsql_createTemporaryLob(LobPlsqlUtil.java:1354)
         at oracle.jdbc.dbaccess.DBAccess.createTemporaryLob(DBAccess.java:997)
         at oracle.sql.LobDBAccessImpl.createTemporaryClob(LobDBAccessImpl.java:240)
         at oracle.sql.CLOB.createTemporary(CLOB.java:527)
         at org.tennet.utils.bc4j.ApplicationModuleImpl.createClob(ApplicationModuleImpl.java:278)
         at org.tennet.utils.bc4j.ApplicationModuleImpl.createClobDomain(ApplicationModuleImpl.java:299)
         at org.tennet.nevada.loader.ResultLoader.executeProcedure(ResultLoader.java:243)
         at org.tennet.nevada.loader.ResultLoader.process(ResultLoader.java:77)
         at org.tennet.nevada.broker.processor.RequestProcessor.processResult(RequestProcessor.java:374)
         at org.tennet.nevada.broker.processor.LoadFlowVAProcessor.process(LoadFlowVAProcessor.java:132)
         at org.tennet.nevada.broker.RequestHandler.processRequest(RequestHandler.java:289)
         at org.tennet.nevada.broker.RequestHandler.run(RequestHandler.java:137)
    This error started when I began using Data Sources instate of direct JDBC Connections.
    The problem is there is no source available for this class so I can’t look what is causing the Nullpointer Exception.
    Can someone tell me what is causing this problem?
    Regards,
    Dennis Labordus

    Hi Dennis,
    I have had the same problem as this. I am going to get onto Oracle via Metalink about it.
    However - there is a work around.
    We are using OC4J with its data sources.
    There is a method on the OC4J Connection called getCoreConnection(Connection). This returns the underlying Oracle connection.
    If you then pass this underlying oracle connection to CLOB.createTemporary() it works.
    We had to use reflection to call the method as I couldn't seem to cast it statically.
    Paul McHugh
    * getOracleConnection
    * Derive oracle connection from DataSource connection
    private static OracleConnection getOracleConnection (Connection connection) throws SQLException
    System.err.println ("UserTypeImpl.getOracleConnection: " + connection);
    * Check for an existing oracle connection
    * This should be the case in a database deployment
    if (connection instanceof oracle.jdbc.driver.OracleConnection)
    System.err.println (" Connection is already the base Oracle Connection" + connection);
    return (OracleConnection) connection;
    * Check for an OC4J deployment
    else
    System.err.println (" Searching for core connection ...");
    Object conObj = (Object) connection;
    Class conclass = conObj.getClass();
    OracleConnection coreCon = null;
    Method meth = null;
    // Locate method getCoreConnection on Orion data source
    try {
    Class[] parameterTypes = new Class[] {java.sql.Connection.class};
    meth = conclass.getMethod("getCoreConnection", parameterTypes);
    } catch (NoSuchMethodException e)
    e.printStackTrace();
    throw new SQLException ("UserTypeImpl.getOracleConnection: No such method: getCoreConnection: " + e);
    // Invoke method getCoreConnection on orion data source
    try {
    Object[] args = new Object[] {connection};
    coreCon = (OracleConnection) meth.invoke(conObj, args);
    catch (InvocationTargetException e)
    e.printStackTrace();
    throw new SQLException ("UserTypeImpl.getOracleConnection: Invoke: getCoreConnection: " + e);
    catch (IllegalAccessException e)
    e.printStackTrace();
    throw new SQLException ("UserTypeImpl.getOracleConnection: Invoke: getCoreConnection: " + e);
    if (coreCon != null)
    System.err.println (" Core connection found: " + coreCon);
    return coreCon;
    } else
    System.err.println (" Unable to locate core connection.");
    throw new SQLException ("UserTypeImpl.getOracleConnection: Unable to locate core oracle connection.");

  • URGENT:classcastexception

    hi..i m building a site just like online testing...i ve made a loginform.jsp for getting entered and a test.jsp on which questions will b displayed dynamically...but when i press the back button after getting logon and after printing the first question, i get the class castexception.so i ve to close the browser and reopen to do that again...can somebody tell me the problem..
    and when i press the refresh button...it wont print the next answer...why is that so............plz reply...

    i ve used two javabeans.tell me which 1 to send u.1 for checkin if user already exists.here is it....package papersonline;
    import java.sql.*;
    import javax.sql.*;
    import java.util.*;
    import javax.naming.*;
    public class MyB
         Connection CN,CN1;
         PreparedStatement SQL,SQL1;
         ResultSet RS,RS2;
         public String checkUser(String s,String sss)throws Exception
                   String name=null;
                   name=s;     
                   String ppp=null;
                   ppp=sss;
                   Class.forName("org.gjt.mm.mysql.Driver");
                   CN =
    DriverManager.getConnection("jdbc:mysql://127.0.0.1/test");
                   SQL = CN.prepareStatement(" select * from users
    where name= ? and password= ? ");          
                   SQL.setString(1,name);
                   SQL.setString(2,ppp);
                   RS=SQL.executeQuery();
                   if(RS.next())
                        return "false";//user already exists
                   else
                        return "true";//user doe'snt exist     
         public String addUser(String names,String passwords)throws
    Exception
                   String name="";
                   String password="";
                   name=names;
                   password=passwords;                    
                   Class.forName("org.gjt.mm.mysql.Driver");
                   CN1 =
    DriverManager.getConnection("jdbc:mysql://127.0.0.1/test");
                   SQL1=CN1.prepareStatement("insert into users
    values(?,?)");
                   SQL1.setString(1,name);
                   SQL1.setString(2,password);
                   int rs2 = SQL1.executeUpdate();
                   if(rs2>=1)          
                        return "record added ";          
                   else
                        return "record not added";
    }

  • Problem while using oracle.sql.CLOB

    Hello,
    I was trying to use oracle.sql.CLOB to update CLOB types in database. I was able to successfully run the update when I use the connection obtained from normal DriverManager.getConnection method. But have issues when I use a datasource lookup, Am using Websphere as my JDBC provider environ.
    The exception I get during the execution of this line is
    oracle.sql.CLOB newClob = oracle.sql.CLOB.createTemporary((java.sql.Connection)conn, false, oracle.sql.CLOB.DURATION_CALL);
    java.lang.ClassCastException: com.ibm.ws.rsadapter.jdbc.WSJdbcConnection
    as my connection is obtained by DataSource.getConnection() method.
    Is this a documented limitation of Oracle SQL CLOB class or is there a way I can tweak the code to work.
    Am using a oracle 9i thin driver
    Thanks
    Message was edited by:
    caniknow

    With the new Oracle drivers there is no need to do it that complicated.
    Finally Oracle has implemented the standard JDBC calls, and inserting a CLOB is really easy now:
    String clobContent  = populateClobData(); // whatever...
    stmt = con.prepareStatement("INSERT INTO clob_table (id, clob_col) VALUES (?,?)";
    stmt.setInt(1, 42);
    Reader r = new StringReader(clobContent);
    stmt.setCharacterStream(2, r, clobContent.length());
    stmt.executeUpdate();
    con.commit();This works with UPDATE as well. If you need to deal with BLOBs simply use setBinaryStream().
    Reading is done using getCharacterStream() or getBinaryStream()
    This actually works across all (or at leas all major) database systems

  • XMLTYPE as CLOB storage "inserting large xml document in xml type column"

    Hi All,
    i have a table containing an xml datatype(non schema based)
    i would like to insert a large xml document in it
    but an exception is thrown-->"string literal too long"
    i tried to use bind variables as a solution"prepared statements as i write in java"
    but it didn't work....as xml document is large
    when i tried to change the column type to CLOB,it worked but without xml validataion,
    although the xml type is mapped to a CLOB in storage, xml type couldn't insert the document
    if anyone have a solution plz tell,i needed it urgently
    thanks,in advance :-)

    thx it was very useful :-)
    but i am not having any success getting the following statement working using a JDBC connection pool rather than a hard coded URL connection
    tempClob = CLOB.createTemporary(conn, true, CLOB.DURATION_SESSION);
    it works with:
    "jdbc:oracle:thin:@server:port:dbname"
    Does NOT work with:
    datasource.getConnection()
    if anyone colud help...

  • HELP:Problem in creating a temporary CLOB using JDBC connection pooling

    Hi All,
    i am inserting a large xml document in an xml type column by creating a temporary clob of this document
    tempClob = CLOB.createTemporary(conn, true, CLOB.DURATION_SESSION);
    I am not having any success getting the following statement working using a JDBC connection pool rather than a hard coded URL connection
    it works with:
    "jdbc:oracle:thin:@server:port:dbname" connection
    Does NOT work with:
    datasource.getConnection()
    Does any one know how to successfully get this to work?
    urgently plz........

    Hi Dharmi
    Here is a quote of Dafna's post in [another thread in this forum|Re: Copy VC controls]
    CE7.1.1 will be released at September 2008 for ramp-up customers.
    There are many improvements and new capabilities in the new release of Visual Composer for CE7.1.1. Among the new features you can find:
    The missing features from Visual Composer 7.0 (Html view, portal Eventing support (EPCM), JDBC, Undo/Redo, and more..)
    Many layout & modeling improvements
    Additional ALV table functionality - export to Excel, switch to chart, configure ALV behavior at design time
    Integration of Visual Composer in Eclipse - additional entry point to the Visual Composer models from the NWDS. This integration provides the option to add a WD component (in case of missing functionality in Visual Composer), as a black box component to the Visual Composer model. Right-clicking the component will open the Web Dynpro perspective for creating/modifying the component.
    Regards,
       Shai

  • Convert String to CLOB problem, CLOB is a input parameter in the procedure.

    I can not flush and close "Writer"??
    The following code:
    CLOB inclob=null;
    CallableStatement csr=conn.prepareCall ("begin TestClob(?); end;");
    csr.registerOutParameter (1, Types.CLOB);
    inclob = CLOB.createTemporary(conn,false,CLOB.DURATION_CALL);
    inclob .open(CLOB.MODE_READWRITE);
    Writer tempClobWriter = inclob.getCharacterOutputStream();
    tempClobWriter.write("This is In CLOB");
    // Flush and close the stream
    tempClobWriter.flush(); // problem is here
    tempClobWriter.close();//problem is here
    inclob.close();// this works
    Btw:
    How to use CLOB.setString() to specify string to CLOB directly?
    Message was edited by:
    user515324

    sorry, I fogot mention the error is "No data to read from socket"
    My Oracle JDBC driver is 9.2.0.4, Oracle database is 10.2.1.0
    Some guy said it is driver's problem.

  • $200 reward to solve problem with JDBC and CLOB.getCharacterOutputStream

    I'm trying to update CLOB with the getCharacterOutputStream as suggested in the example code. It works with US7ASCII DB instance but not instances in UTF8.
    I've been browsing through all the Oracle doc's and found some rather confusing statements:
    In the page at http://oradoc.photo.net/ora816/java.816/a81354/oralob2.htm#1043220
    it says: [When writing to or reading from a CLOB, the JDBC drivers perform all character set conversions for you.]
    also: [The oracle.sql.CLOB class supports all the character sets that the Oracle data server supports for CLOB types.]
    So far so good.
    In the page at http://oradoc.photo.net/ora816/java.816/a81354/oraint3.htm#1012518
    it says [The oracle.sql package supports these datatypes in several ways: CLOBs point to large fixed-width character data items (that is, characters that require a fixed number of bytes per character) and are supported by the oracle.sql.CLOB class.]
    Ooh no! Is this for real? UTF8 is variable width and does this mean it is not supported?
    Any way to get around this?
    In the page at http://oradoc.photo.net/ora816/java.816/a81358/03_pub2.htm#36009
    says [6.The mappings to oracle.sql classes are optimal because they preserve data formats and require no character-set conversions (apart from the usual network conversions). Those classes are especially useful in applications that "shovel" data between SQL and Java.]
    "No character set conversion"? Very confusing!
    I've been hammering on this CLOB/JDBC/UTF8 problem for more than a week now and I really appreciate some solutions, workarounds, or whatever help I can get. I'm running java stored procedure in 8.1.6 on Linux RH6.2.
    For your trouble, I'd pay $200 for the first guy who come up with a verifiable solution.

    This is just findings based upon your comments:
    Please refer to document Oracle8i National Language Support Guide
    Release 2 (8.1.6) from Oracle Documentation Library, Release 8.1.7
    Chapter 6 Java,
    There its clearly mention that:
    "Oracle JDBC drivers provide globalization support by allowing users to retrieve data from or insert data into a database in any character set that Oracle supports. Because Java strings are UCS2 encoded (16-bit Unicode) for JDBC programs, the target character set on the client is always UCS2. Character set conversion is required to convert data from the database character set (Db Charset) to UCS2. This applies to CHAR, LONG, CLOB, and VARCHAR2 data types; RAW data is not converted. "
    Also..please refer this...
    "oracle.sql.CLOB's method getCharacterStream() returns the contents of a CLOB as a Unicode stream."
    "The techniques that Oracle's drivers use to perform character set conversion for Java applications depend on the character set the database uses. The simplest case is where the database uses a US7ASCII or WE8ISO8859P1 character set. In this case, the driver converts the data directly from the database character set to UCS2,which is used in Java applications. "
    "If you are working with databases that employ a non-US7ASCII or non-WE8ISO8859P1 character set (for example, Japanese or Korean), then the driver converts the data, first to UTF8, then to UCS2. "
    In my case the characte-set of the database is WE8ISO8859P1 and for security reason i can't change the character set but my feeling is that if you are updating the CLob from the java client you are forming a reference of a clob in the client which is UCS2 at the Java side. Now when you are populating the clob through java.io.Writer and call the procedure to pass the reference of the clob to the procedure then I believe the JDBC will convert the UCS2 datatype of Clob to UTF8 in the database.
    You can try out the code snippet:
    package ServletGDC;
    import java.io.*;
    import java.util.*;
    import javax.servlet.*;
    import javax.servlet.http.*;
    import oracle.sql.*;
    import java.sql.*;
    import oracle.jdbc.driver.*;
    import ClassesGDC.*;
    public class testUpload extends HttpServlet {
    private String m_strMessage="";//It stores the message to be uploaded along with the Document
    Connection conn=null;
    public void doPost(HttpServletRequest req, HttpServletResponse res)
    throws ServletException, IOException {
    String strContent="";
    //res.setContentType("application/msword");
    res.setContentType("text/html");
    PrintWriter out = res.getWriter();
    try {
    CallableStatement cmt=null;
    OutputStream output=null;
    ByteArrayOutputStream byteoutput=null;
    String strDocString="";
    oracle.sql.CLOB tempClob = null;
    String strPassedFileName="";     // the file name passed in the request object
    String strStdFilename="";//the file name to be given to the best practice
    String strSaveDirectory="";     //the directory in which the bp is to be saved
    String strParamName="";//name of parameters
    String strParamValue="";//value of parameters
    int intTempVariable=0; // temporaty variable
    long lngSizeOfFileUploaded=0;//stores the size of the file which had been uploaded in the file system
    File filePathOfFileUploaded=null;//stores the path of the file uploaded to the file system
    String strQuery="";
    //ST------------checks if the user has logged in or not-----------------------
    HttpSession session=req.getSession(true);
    if(req.getContentLength()>20*1024*1024)
    throw new skip("The size of the posted content is more than 10 MB . If you have a best practice whose size is more than 1 MB please mail it to Us.");
    byteoutput = new ByteArrayOutputStream();
    MultipartParser mp = new MultipartParser(req, 20*1024*1024); // 10MB is the limit of the file to be uploaded
    Part part;//Its an abstact part which helps in retrieving information about the file and the parameters
    while ((part = mp.readNextPart()) != null) {//Reads the next part
    strParamName = part.getName();
    // the following if is executed if the part is for a parameter rather than a file
    if (part.isParam()) {
    }else if (part.isFile()) {
    // it's a file part
    m_strMessage="inside file part";
    FilePart filePart = (FilePart) part;
    strPassedFileName = filePart.getFileName();
    strContent= filePart.getContentType();
    out.println("<BR><font color=red>strPassedFileName is "+strPassedFileName+"</font>");
    if(strPassedFileName != null || !(strPassedFileName.trim().equals("")) ) {
    // the part actually contained a file
    out.println("<BR><font color=red> before forming long</font>");
    //lngSizeOfFileUploaded = filePart.writeTo(filePathOfFileUploaded);      //the statement upload the bestpractice in the
    lngSizeOfFileUploaded = filePart.writeTo(byteoutput);     //specified file path filePathOfFileUploaded.
    out.println("<BR><font color=red> after file is written into the outputstream</font>");
    else {
    throw new skip("The file name is null or it is empty space. Files in such Format are not accepted");
    }//end of else if
    }//end of while loop
    if(     lngSizeOfFileUploaded==0)     {// the size of the file uploaded is zero then the file supplied was not proper and hence exception is to be thrown
    //if(filePathOfFileUploaded.exists())
    //     filePathOfFileUploaded.delete();
    throw new skip("The File could not be uploaded,Possible reasons may be that the file is sent null or the file is corrupted");
    //END---------------the file is uploaded in the proper directory--------------------
    //res.setContentType(strContent);
    out.println("<BR><font color=red>long value is : "+lngSizeOfFileUploaded+" and content is "+strContent+"</font>");
    String strbyte= byteoutput.toString();
    byteoutput.flush();
    Class.forName("oracle.jdbc.driver.OracleDriver");
    // Establish network connection to database
    conn = DriverManager.getConnection("jdbc:oracle:thin:@pc-p32670:1521:GDCDBI","gdc_user","myuser");
    //if(conn!=null)
    out.println("<BR><font color=red>Connection formed"+conn);
    //els
    //out.println("<BR><font color=red>long value is : "+strbyte+"</font>");
    try{
    tempClob = oracle.sql.CLOB.createTemporary(conn,true, oracle.sql.CLOB.DURATION_SESSION);
    out.println("<BR><font color=red>tempClob : "+tempClob);
    tempClob.open( oracle.sql.CLOB.MODE_READWRITE);
    java.io.Writer tempClobWriter = tempClob.getCharacterOutputStream();
    // writing the string formed from the multipart file to the clob
    tempClobWriter.write(strbyte);
    if(tempClob!=null){}
    out.println("<BR><font color=red>CLOB value is : "+tempClob+"</font>");
    strQuery="{call INSERT_CLOB(?,?)}";
    cmt=conn.prepareCall(strQuery);
    cmt.setString(1,strPassedFileName);
    cmt.setClob(2,tempClob);
    cmt.registerOutParameter(2,java.sql.Types.CLOB);
    cmt.execute();
    tempClobWriter.flush();
    tempClobWriter.close();
    tempClob.freeTemporary();
    //res.setContentType(strContent);
    //strDocString.toString();
    out.println("<BR><font color=red>bob is "+strbyte+"</font>");
    tempClob.close();
    }catch(Exception e){
    tempClob.close();
    out.println("<font color=blue> Error is :"+e.getMessage()+"</font>");
    //e.printStackTrace(out);
    cmt.close();
    //out.println("<BR><font color=red><h2><b>SUCCESS</h2></font>");
    //res.sendRedirect("../test/showfile.jsp?contentype="+strContent.trim()+"");
    }catch(Exception e){
    java.util.Date d = new java.util.Date();
    String s =d.toString();
    out.println("<font color=blue> Error is :"+e.getMessage()+"</font>");
    //e.printStackTrace(out);
    }finally{
    try{
    if(conn!=null)
    conn.close();
    }catch(Exception e){
    out.println("<font color=blue> Error is :"+e.getMessage()+"</font>");
    }// end of finally
    } //end of doPost
    } //end of class
    in the Procedure you will be inserting/updating the clob in a table with the reference clob in the out parameter of the procedure
    Thanks.

  • Error updating a CLOB XML fragment

    Hi,
    I have an xml schema that contains an element of type xs:anyType that has been mapped to Oracle as CLOB.
    Now I have the needs to update this value but I was not able to do it.
    The code that does the update is the following:
    public void updateXML(String sqlCmd, String XMLString) throws Exception
    DataSource ds = null;
    Connection conn = null;
    OraclePreparedStatement stmt = null;
    oracle.sql.CLOB tempCLOB = null;
    Writer tempCLOBWriter= null;
    try
    //Get Data Source
    ds = (DataSource) new InitialContext().lookup(xmlDS);
    // Get Connection
    conn = ds.getConnection();
    // Prepare statement with requested insert, update or delete statement
    stmt = (OraclePreparedStatement) ((OracleConnection) conn).prepareStatement(sqlCmd);
    // Build CLOB containing XML if required
    if (XMLString != null)
    tempCLOB = oracle.sql.CLOB.createTemporary
    ( ((WLConnection)conn).getVendorConnection(),
    true,
    CLOB.DURATION_SESSION);
    try {
    tempCLOB.open(CLOB.MODE_READWRITE);
    tempCLOBWriter = tempCLOB.getCharacterOutputStream();
    tempCLOBWriter.write(XMLString);
    tempCLOBWriter.flush();
    } finally {
    if (tempCLOBWriter != null)
    tempCLOBWriter.close();
    //Set parameter on Prepared Statement
    stmt.setCLOB(1,tempCLOB);
    // Execute command
    stmt.executeUpdate();
    // Clean up CLOB data if required
    if (XMLString != null)
    tempCLOB.freeTemporary();
    // Return connection to the pool
    conn.close();
    catch ( Exception e)
    if (conn != null)
    conn.close();
    throw e;
    IF the sqlCmd param contains:
    update XML_OPERAZIONE_LOG t
    set value(t) = updateXML(value(t),
    '/operazione.log/Operazione',XMLTYPE(?))
    where existsNode(value(t),
    '/operazione.log/Journal [NumeroElettronico="99900000"]') = 1
    I get the error ORA-17410 "No More Data to read from socket"
    If the sqlCmd contains:
    insert into XML_OPERAZIONE_LOG values( XMLType(?))
    I have no problems.
    Any Idea ?
    Oracle 9.2.0.2.0, latest classes12.zip BEW Web Logic 8.1

    Upgrade to 9.2.0.5.0 since 9.2.0.2.0 is not supported for XMLType. Also try OCI rather than thin dirver.

  • Inserting to a CLOB field in Oracle 8i  Database

    Hi All,
    I am trying to insert a value to a CLOB field in Oracle 8i DB.
    The value gets inserted when the size is less (Up to around 80 Bytes).
    When the size becomes larger the insertion does not take place but no exception is thrown.
    Please see below the code I have written.
    PreparedStatement preparedStatement = null;
              try {
                   connection = getConnection(MMAKeys.WMDS_DATASOURCE);
                   String query = "UPDATE s_mmhp_batch SET MMHP_REPORT_CLOB=(?) WHERE MMHP_BATCH_ID=(?) AND MMHP_USER_ID=(?) AND MMHP_MEMBER_KEY=(?)";
              preparedStatement=connection.prepareStatement(query);
              Reader r = new StringReader(clobReport);
              preparedStatement.setCharacterStream(1, r, clobReport.length());
              oracle.sql.CLOB newClob = oracle.sql.CLOB.createTemporary(connection , false, oracle.sql.CLOB.DURATION_CALL);
              newClob.putString(1,clobReport);
              preparedStatement.setClob(1,newClob);
              preparedStatement.setInt(2,batchId);
              preparedStatement.setString(3,userId);
              preparedStatement.setString(4,memberKey);
              preparedStatement.executeUpdate();
              System.out.println("inside the write to Batch method after executing the query");
              } catch (SQLException exception) {
                   throw new DAOException(
                        "MREDMMSDAO -> writeToTable():SQLException"
                             + exception.getMessage());
              } catch (Exception exception) {
                   throw new DAOException(
                        "MREDMMSDAO -> writeToTable():Exception"
                             + exception.getMessage());
              } finally {
                   closeStatement(preparedStatement);
                   closeConnection(connection);
    I came to know that this method is not supported in Oracle 8i.
    I tried to create an empty CLOB and call the putValue() method.
    But Then, I got an exception stating that the method is not supported.
    Is there any other way to insert a CLOB value to Oracle 8i?
    Please help.
    Thanks in advance,
    Neelambary

    And cursor.callproc('insert_clob_proc', (clob,))
    doesn't work for you?
    PrzemekYes - I should have been more clear in my original post. The callproc function works until we have a value which is over 32K. At values over 32K, we get an error message "ORA-01460: unimplemented or unreasonable conversion requested". I believe this is because we are sending the value as a string and so we would need to figure out how to send as a CLOB in cx_Oracle? Here is some code to use to test if interested...
    Oracle (Oracle Database 10g Release 10.1.0.4.0 - Production):
    CREATE TABLE clob_test (CLOB_FIELD CLOB);
    CREATE OR REPLACE PROCEDURE ins_clob_test (v_clob_field IN CLOB)
    AS
    BEGIN
    INSERT INTO clob_test (clob_field) VALUES (v_clob_field);
    END ins_clob_test;
    Python (2.5):
    conn = cx_Oracle.connect(xhash['oraclelogin'])
    cursor = conn.cursor()
    clob_var = 'Some test data' * 10000
    cursor.callproc('ins_clob_test',(clob_var,))
    conn.commit()
    cursor.close()
    conn.close()
    I should also mention that I am the Oracle developer and not the Python programmer - my knowledge of Python is very limited. I would like the Python programmers to use the procedures (packages) I have created to do their inserts but this situation has caused them to put the SQL directly in their code.
    Thanks again for any assistance you can provide.
    Jason

  • Problem in creating Oracle CLOB thorough JAVA

    HI,
    I am facing problem in inserting CLOB data through Oracle.
    My code sends exception at below java code line:-
    oracle.sql.CLOB newClob = oracle.sql.CLOB.createTemporary(nativeConnection,false, oracle.sql.CLOB.DURATION_SESSION);
    Exception is:::::
    ===========
    11/08/10 19:12:33 InsertQuery is::::::>>>>INSERT INTO MCREDIT_XML (Inmxml,outmxml,app_id_c,REQUEST_ID,request_date) values (?,?)
    11/08/10 19:12:50 Error In Clob----->oracle.jdbc.internal.OracleConnection oracle.jdbc.OracleConnection.physicalConnectionWithin()
    com.evermind.server.rmi.OrionRemoteException: Transaction was rolled back: java.lang.AbstractMethodError: oracle.jdbc.internal.OracleConnection oracle.jdbc.OracleConnection.physicalConnectionWithin()
    at QdeMain_StatelessSessionBeanWrapper50.processRequest(QdeMain_StatelessSessionBeanWrapper50.java:158)
    at com.nucleus.los.bean.trackinginterface.ejb.DedupeExtBean.onMessageMCredit(DedupeExtBean.java:153)
    at com.nucleus.los.bean.trackinginterface.ejb.DedupeExtBean.onMessage(DedupeExtBean.java:82)
    at com.evermind.server.ejb.MessageDrivenBeanInvocation.run(MessageDrivenBeanInvocation.java:123)
    at com.evermind.server.ejb.MessageDrivenHome.onMessage(MessageDrivenHome.java:745)
    at com.evermind.server.ejb.MessageDrivenHome.run(MessageDrivenHome.java:916)
    at com.evermind.util.ReleasableResourcePooledExecutor$MyWorker.run(ReleasableResourcePooledExecutor.java:186)
    at java.lang.Thread.run(Thread.java:534)
    Nested exception is:
    java.rmi.RemoteException: oracle.jdbc.internal.OracleConnection oracle.jdbc.OracleConnection.physicalConnectionWithin(); nested exception is:
    java.lang.AbstractMethodError: oracle.jdbc.internal.OracleConnection oracle.jdbc.OracleConnection.physicalConnectionWithin()
    at com.evermind.server.ejb.EJBUtils.makeException(EJBUtils.java:941)
    at QdeMain_StatelessSessionBeanWrapper50.processRequest(QdeMain_StatelessSessionBeanWrapper50.java:158)
    at com.nucleus.los.bean.trackinginterface.ejb.DedupeExtBean.onMessageMCredit(DedupeExtBean.java:153)
    at com.nucleus.los.bean.trackinginterface.ejb.DedupeExtBean.onMessage(DedupeExtBean.java:82)
    at com.evermind.server.ejb.MessageDrivenBeanInvocation.run(MessageDrivenBeanInvocation.java:123)
    at com.evermind.server.ejb.MessageDrivenHome.onMessage(MessageDrivenHome.java:745)
    at com.evermind.server.ejb.MessageDrivenHome.run(MessageDrivenHome.java:916)
    at com.evermind.util.ReleasableResourcePooledExecutor$MyWorker.run(ReleasableResourcePooledExecutor.java:186)
    at java.lang.Thread.run(Thread.java:534)
    Caused by: java.lang.AbstractMethodError: oracle.jdbc.internal.OracleConnection oracle.jdbc.OracleConnection.physicalConnectionWithin()
    at oracle.sql.CLOB.createTemporary(CLOB.java:684)
    at oracle.sql.CLOB.createTemporary(CLOB.java:651)
    at com.nucleus.los.dao.daofactory.OracleDAOFactory.executePreparedUpdateClob(OracleDAOFactory.java:2352)
    at com.nucleus.los.bean.application.qde.MCreditInterfaceBean.processRequest(MCreditInterfaceBean.java:171)
    at com.nucleus.los.bean.application.qde.ejb.QdeMainBean.processRequest(QdeMainBean.java:84)
    at QdeMain_StatelessSessionBeanWrapper50.processRequest(QdeMain_StatelessSessionBeanWrapper50.java:101)
    ... 7 more

    AbstractMethodErrorThat occurs when something wants to call a method which does not exist.
    For example if something expects JDBC 4 but the jdbc driver that is being used is for JDBC 2.

Maybe you are looking for

  • Safari problem with Vimeo

    when I start to watch a video on vimeo with Safari (8.0 with Yosemite ) when I pause to wait for the video to download completely (i have a slow connection) and change the window while I wait for the video to be fully downloaded safari stops download

  • Sub-details in the same report at a double click

    Hi All, Can anyone let me know how to display the below details in the report? Initially we can display the basic list with month details. Say we have 12 months (12 lines) in the output. Now if I double click on the month (say March), in the same rep

  • I uploaded Canon VIXIA HF R400 footage at Full HD 1080 35Mbps 60p, 1080 17Mbps, and 720 4Mbps MP4

    I took the time to upload a Playlist of Full HD 35Mbps 60p, Winter Scenes 17Mbps 30p, the horrible Samsung HMX-F90 vs the Canon at 1280x720 4Mbps. So it covers the bases. Meanwhile I hope you enjoy my efforts of what this cam can look like: https://w

  • Older version of XCode

    Hello all! I'd like to buy myself a new Macbook in 4 months or so, but for now I have to use my old Macbook to program. If I download an older version of XCode, and it says iOS5 for example, does this mean that the version is only for iOS5 or everyth

  • Upgrede 11.1.0.6.0 to 11.1.0.7.0 or higher

    Dear Friends, I try to install the oracle BI 11.5, but my oracle database version is not support. It require to the database version equal or higher 10.2.0.4 and equal or higher 11.1.0.7.0. So, I hope you guys will help me to upgrade my database. Tha