db-torque-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Robert Bowen <s...@yahoo.com>
Subject How to save / load LOBs in Postgres with Torque
Date Tue, 02 Nov 2004 17:00:42 GMT
I have been looking high and low for the best way to
do this. Unfortunately the Postrgres How-To is not up
to date (as mentioned in one of the messages in this
list) and there doesn't seem to be a concensus on how
to do this.

I have done the following:

1. Set up a VARBINARY field in my schema
2. Defined a bytea field in my database
3. To save the file (which is a Word doc) I do the
following:

byte buf[] = new byte[2048];
int s, tl = 0;
while ((s = bis.read(buf, 0, 2048)) > 0) {
   tl += s;
}

myDAO.setLOBField(buf);
myDAO.save();

And to load it I do the following:

byte buf2[] = myDAO2.getFitxer();
OutputStream out = new FileOutputStream("myFile");
out.write(buf2);
out.close();

... And all I get is a bunch of junk when I open it in
Word. 

Can anyone give me a hand with this?

Many thanks,
syg


		
__________________________________ 
Do you Yahoo!? 
Check out the new Yahoo! Front Page. 
www.yahoo.com 
 


---------------------------------------------------------------------
To unsubscribe, e-mail: torque-user-unsubscribe@db.apache.org
For additional commands, e-mail: torque-user-help@db.apache.org


Mime
View raw message