Results 1 to 3 of 3
  1. #1
    Join Date
    Mar 2004
    Posts
    25

    Question Unanswered: Error using Clob Datatype

    hi ,

    I am having trouble using clob data type. when i enter any value in this field they show some thing like com.daffodilwoods.rmi.a_1942@2c45b65 .

    Is this a bug or i am using the datatype in a wrong way?
    please help me this is really bothering me.


    lalit

  2. #2
    Join Date
    Mar 2004
    Posts
    25

    Thumbs down

    please help me fast
    Last edited by Webmaster; 06-05-04 at 09:03.

  3. #3
    Join Date
    Jun 2004
    Posts
    3

    sol

    Hi ,

    This is not a bug, you are definitely using the clob field in a wrong manner.

    The following program demonstrates how to use clob fields:

    private void clobUsage(Connection con) {

    try {
    Statement stt = con.createStatement();
    String createTable = "create table clobTable( columnOne clob)";
    dropTable(stt,"clobTable");
    stt.execute(createTable);
    InputStream tempStream = getClass().getResourceAsStream("DaffodilDBReadMe.t xt");
    InputStreamReader reader = new InputStreamReader(tempStream);
    PreparedStatement ps = con.prepareStatement(
    "insert into clobTable values(?)");
    for (int i = 0; i < 1; i++) {
    ps.setCharacterStream(1, reader, tempStream.available());
    // ps.setAsciiStream(1, tempStream, tempStream.available());
    ps.executeUpdate();
    }
    ResultSet rs = stt.executeQuery("select * from clobTable");
    while (rs.next()) {
    for (int i = 1; i <= rs.getMetaData().getColumnCount(); i++) {
    Clob clob = rs.getClob(i);
    Reader read = clob.getCharacterStream();
    String text = null;
    if (read != null) {
    CharArrayWriter writer = new CharArrayWriter();
    char[] buf = new char[1024];
    int count = read.read(buf, 0, buf.length);
    while (count > 0) {
    writer.write(buf, 0, count );
    count = read.read(buf, 0, buf.length);
    }
    read.close();
    text = new String(writer.toCharArray());
    writer.close();
    }
    else {
    System.out.println("Stream is null");
    return ;
    }
    JFrame frame = new JFrame("Daffodil DB -- Clob Usage");
    frame.setDefaultCloseOperation(frame.HIDE_ON_CLOSE );
    JTextArea label = new JTextArea(text);
    JScrollPane scrollpane = new JScrollPane(label);
    label.setLineWrap(true);
    label.setWrapStyleWord(true);
    frame.getContentPane().add(scrollpane);
    frame.setSize(400, 400);
    frame.show();
    }
    }
    }
    catch (IOException ex) {
    ex.printStackTrace();
    }
    catch (SQLException ex) {
    ex.printStackTrace();
    }
    }



    You can also find the related documentation in DaffodilDB3_1\samples\sample.java in the directory where you have installed the Daffodil DB.

    from
    Ashish

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •