General J2EE: how to get XML from InputStream to Oracle CLOB format?

  1. hi,

    there's a servlet in another webserver I have to connect to via an URL. the servlet returns an XML as a servlet response (stream). I need to send this XML as CLOB datatype into Oracle 9i database.
    I need to get the InputStream into the Oracle CLOB datatype, without saving it into a file first.

    Here's what I have come up with so far:
    url1= new URL ("https://blahblah");
    istream = url1.openStream();
    char[] buffer = new char[size];
    InputStreamReader reader = new InputStreamReader(istream);
        for (int charRead = reader.read(buffer); charRead > -1; charRead = reader.read(buffer)) {

            // here I need to write into CLOB


    any ideas?
  2. Not tested, but something like this should do it:

    CLOB myClob = CLOB.createTemporary(connection, false, CLOB.DURATION_CALL);
    Writer clobWriter = myClob.getCharacterOutputStream();

    // Write from Reader to Writer here
    // You can call ps.setClob() with this object