For SQL server 6.5 data type text maps to JDBC Longvarchar. I use a PreparedStatement.setString()
to store the text and ResultSet.getString() to retrieve it.
 
The data type image maps to the JDBC type Longvarbinary, so I would assume that you could use PreparedStatment.setBytes() to store and a ResultSet.getBytes() to retrieve although I have never implemented this. A byte array that is very large could use the ResultSet.getBinaryStream() or the PreparedStatement.setBinaryStream(). You can look through the java.sql package for more info.
 
 
Corey Frye                                          Network Programmer
Motorsport Simulations Inc.               (972) 910-8866 ext. 102
100 East Royal Lane Suite 130        http://www.motorsims.com
Irving, Texas 75039                            [EMAIL PROTECTED]
-----Original Message-----
From: Sun Kehao <[EMAIL PROTECTED]>
To: [EMAIL PROTECTED] <[EMAIL PROTECTED]>
Date: Tuesday, August 17, 1999 5:33 PM
Subject: asking for help

I'm sorry to post a seemingly topic-irrelated problem. In my servlet, I want to store a
text file(such as .doc) and a image file(such as .jpg) to the fields 'text' or 'image' of
MS SQL Server 6.5. But I don't know how to store and how to retrieve them.
I've searched archives with no luck.
 
Some codes are
 
      RandomAccessFile f = new RandomAccessFile(
         "servlets\\MediaFiles\\"+fileName[0], "r");
      int size = (int)f.length();
      byte[] buff = new byte[size];
      f.readFully(buff, 0, size);
 
I use "declare @imgpageptr varbinary(16)
select @pageptr=textptr(ImgCol) from sqltbl where Rowid = 1
write sqltbl.imgCol @pageptr with log" + buff
(or readtext sqltbl.imgCol @pageptr 0  0)
 
Am I making an obvious mistake.
 
Could someone here help me out please.
 
thanks,
 
Kehao
 
 

Reply via email to