Loading ...
Sorry, an error occurred while loading the content.
 

Re: [xml-dbms] retrieving 'Text' columns

Expand Messages
  • Ronald Bourret
    You ll need to modify the code in DBMSToDOM.populateRow. For example, assuming that the returned object is an InputStream, this might be something like the
    Message 1 of 4 , May 14, 2002
      You'll need to modify the code in DBMSToDOM.populateRow. For example,
      assuming that the returned object is an InputStream, this might be
      something like the following (uncompiled, untested) code:

      void populateRow(Table table, Row row, ResultSet rs)
      throws SQLException
      {
      ResultSetMetaData meta = rs.getMetaData();
      char[] buf = new char[4096];

      for (int i = 0; i < row.columnValues.length; i++)
      {
      row.columnValues[i] = rs.getObject(table.rsColumnNumbers[i]);

      if (rs.wasNull())
      {
      ...
      }
      else if (meta.getColumnType(table.rsColumnNumbers[i])) ==
      Types.LONGVARCHAR) // might be LONGVARBINARY
      {
      Reader r = InputStreamReader(row.columnValues[i]);
      StringBuffer sb = new StringBuffer();
      int len;
      while ((len = r.read(buf, 0, 4096)) != -1)
      {
      sb.append(buf, 0, len);
      }
      row.columnValues[i] = sb.toString();
      }
      }
      }

      To go in the other direction (XML => DB), see:

      http://groups.yahoo.com/group/xml-dbms/message/518
      http://groups.yahoo.com/group/xml-dbms/message/1501

      -- Ron


      "Peter V. Mikhalenko" wrote:

      > RB> Is TEXT a LONGVARCHAR? If so, I wonder if your JDBC driver is
      > RB> returning an InputStream or similar object instead of a String
      > RB> object. That would account for the value you're seeing, which looks
      > RB> more like a Java object
      > RB> ID than real data.
      >
      > I'm trying MySQL, so it seems that TEXT is just a BLOB. If JDBC driver is
      > returning an OutputStream, in the returning XML element there is a
      > serialized object? So how can I determine on object type and retrieve its
      > contents in Java? Think I should to do some kind of deserializing...
    Your message has been successfully submitted and would be delivered to recipients shortly.