If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Database Server Software > Other > Error using Clob Datatype

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 06-05-04, 06:48
Webmaster Webmaster is offline
Registered User
 
Join Date: Mar 2004
Posts: 25
Question 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
Reply With Quote
  #2 (permalink)  
Old 06-05-04, 07:25
Webmaster Webmaster is offline
Registered User
 
Join Date: Mar 2004
Posts: 25
Thumbs down

please help me fast

Last edited by Webmaster; 06-05-04 at 08:03.
Reply With Quote
  #3 (permalink)  
Old 06-05-04, 08:07
ashish mhatre ashish mhatre is offline
Registered User
 
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
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On