× The internal search function is temporarily non-functional. The current search engine is no longer viable and we are researching alternatives.
As a stop gap measure, we are using Google's custom search engine service.
If you know of an easy to use, open source, search engine ... please contact support@midrange.com.



the test program:

      Connection con = DriverManager.getConnection("jdbc:as400:reynders", prop);
      System.out.println("Connection created");
      PreparedStatement psGet = con.prepareStatement("SELECT * FROM 
RASTFX.RASF9120 WHERE APLC='RAS'");
      ResultSet rsGet = psGet.executeQuery();
      rsGet.next();
      System.out.println("executeQuery done");
      Clob clob = rsGet.getClob(2);
      System.out.println("Got clob");
      // Reading the contents.
      BufferedReader brInput = new BufferedReader(clob.getCharacterStream());
      System.out.println("Clob length: " +clob.length());
      String line=null;
      try {
        while ( (line = brInput.readLine()) != null) {
          System.out.println(line);
        }
      }
      catch(Exception e) { System.out.println("\nError reading contents: " + 
e.getMessage()); }
      brInput.close();
      // Changing the contents.
      BufferedReader br = new BufferedReader(new 
FileReader("./xmldef/MenuExample.xml"));
      BufferedWriter bw = new BufferedWriter(clob.setCharacterStream(4048));
      while ( (line = br.readLine()) != null) {
        bw.write(line);
      }
      PreparedStatement psSet =con.prepareStatement("UPDATE RASTFX.RASF9120 SET 
XMLF=? WHERE APLC='RAS'");
      psSet.setClob(2, clob);
      psSet.executeUpdate();
      System.out.println("executeUpdate done!");
      psGet.close();
      psSet.close();
      con.close();
    }
    catch(Exception e) {
      System.out.println("Error updating clob: " + e.getMessage());
      e.printStackTrace();
    }



-----Original Message-----
From: Geert Van Landeghem
Sent: dinsdag 5 november 2002 12:29
To: java400-l@midrange.com
Subject: Java Clob


Hello,

Clobs and Blobs are new to me and I couldn't find information on
inserting a row that contains a clob column. Is this possible
or do I have to insert and update the row to change the clob column?

I need to store an xml file into a CLOB column in an AS400 database file.
I've written a small test program that reads a CLOB column with some
dummy info in it.

When reading the contents of the CLOB using a BufferedReader an error
is thrown when the end of information is reached ("Resource not
available"). Is this normal behaviour? Or is the '\r' missing at the
end of the dummy information entered using SQL?

I'm trying to change the contents of the retrieved CLOB by using
clob.setCharacterStream(4048) but this throws another error:
Attribute value not valid. Any idea what I'm doing wrong here?
I would like to read a local xml file and store the contents in
the clob column.


Kind regards,

Geert Van Landeghem


-----Original Message-----
From: Joe Pluta [mailto:joepluta@PlutaBrothers.com]
Sent: dinsdag 5 november 2002 2:14
To: java400-l@midrange.com
Subject: RE: Any color but black.


> From: Booth Martin
>
> Sure Joe.  I wasn't planning on going farther with it, but e-mail me
> off-list.  You didn't sign your post so I don't know how to reach you in
> another venue.

Nah, the thread probably ran it's course anywho.  History is written by the
victor, anyway <grin>.

As to direct email, I'm not sure which mail client you're using, but if
you're using Outlook and you're getting individual emails (as opposed to
digest mode), open the email (by double-clicking) and check the "From:"
address.

Joe

_______________________________________________
This is the Java Programming on and around the iSeries / AS400 (JAVA400-L) 
mailing list
To post a message email: JAVA400-L@midrange.com
To subscribe, unsubscribe, or change list options,
visit: http://lists.midrange.com/cgi-bin/listinfo/java400-l
or email: JAVA400-L-request@midrange.com
Before posting, please take a moment to review the archives
at http://archive.midrange.com/java400-l.

_______________________________________________
This is the Java Programming on and around the iSeries / AS400 (JAVA400-L) 
mailing list
To post a message email: JAVA400-L@midrange.com
To subscribe, unsubscribe, or change list options,
visit: http://lists.midrange.com/cgi-bin/listinfo/java400-l
or email: JAVA400-L-request@midrange.com
Before posting, please take a moment to review the archives
at http://archive.midrange.com/java400-l.



As an Amazon Associate we earn from qualifying purchases.

This thread ...


Follow On AppleNews
Return to Archive home page | Return to MIDRANGE.COM home page

This mailing list archive is Copyright 1997-2024 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].

Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.