× The internal search function is temporarily non-functional. The current search engine is no longer viable and we are researching alternatives.
As a stop gap measure, we are using Google's custom search engine service.
If you know of an easy to use, open source, search engine ... please contact support@midrange.com.


  • Subject: Re: insert blob through sql on 400??
  • From: "Kaushal Trivedi" <e_ediam@xxxxxxxxxxx>
  • Date: Thu, 29 Mar 2001 18:00:24 +0530

Hi everybody,
I found a solution to my problem.
I defined the table with blob externally from a sql DDL instead of pf way
 
 
The following code worked.
I thought if anybody cares to see it will be useful.
 
PreparedStatement ps=MSpEDR03Jv.dbcon.prepareStatement("SELECT * FROM blobtest ");
  ResultSet rs=ps.executeQuery();
  Blob pics=null;
  while(rs.next())
 {
 pics= rs.getBlob("PICTURE");
 
 }
// InputStream logoistrm=pics.getBinaryStream();
 byte[] byteAry=pics.getBytes(1,(int) pics.length());
 FileOutputStream fsfrmdb=new FileOutputStream("dbImage.gif");
 fsfrmdb.write(byteAry);
// logoistrm.read(byteAry);
 ImageIcon dbImage=new ImageIcon("dbImage.gif");
 
Kaush
 
----- Original Message -----
Sent: Wednesday, March 28, 2001 8:18 PM
Subject: Re: insert blob through sql on 400??

I have got the java code that should do the job.
 
PreparedStatement ps=treeCon.prepareStatement("INSERT INTO LOGOFILE (LGBLOB) VALUES (?)");
File f = new File("snslogo.gif");
 
 FileInputStream logoStrm=new FileInputStream(f);
  ps.setBinaryStream(1,logoStrm,(int) f.length());
ps.execute();
 
but when this code is executed on as400 driver SQL Exception is data typr mismatch.
on ODBC driver it says operation not supported.
 
What settings do i require for the db field description. just declaring a field B and length 9 is enough.
Can anybody suggest what may be wrong on the backend.
TIA
Kaush
----- Original Message -----
Sent: Wednesday, March 28, 2001 6:37 PM
Subject: RE: insert blob through sql on 400??

I'm not entirely sure of the JAVA Code, but you might also want to define Content-Type field (in case you need to upload something other than GIF's to the server). 
 

---------------------------------------------------------
Christopher A. Libby, Programmer/Analyst
Maine Public Service Company (www.mainepublicservice.com)
clibby@mainepublicservice.com (207) 768-5811 ext. 2210

-----Original Message-----
From: owner-web400@midrange.com [mailto:owner-web400@midrange.com]On Behalf Of Kaushal Trivedi
Sent: Wednesday, March 28, 2001 7:04 AM
To: WEB400@midrange.com
Subject: insert blob through sql on 400??

I want to insert a gif into a db table.
i have declared the db field to be blob.
can anybody tell me what java code to write to insert a gif obj into db blob field.
thanxx in advance.
Kaush


Maine Public Service Company
www.mainepublicservice.com



Maine Public Service Company
www.mainepublicservice.com


As an Amazon Associate we earn from qualifying purchases.

This thread ...

Replies:

Follow On AppleNews
Return to Archive home page | Return to MIDRANGE.COM home page

This mailing list archive is Copyright 1997-2024 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].

Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.