πŸš€ go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.lang.java.databases
Article #22

Re: Inserting a BLOB into an Oracle BLOB field.

#22
From: Olivier Jousselin
Date: Mon, 24 Mar 2003 14:16
26 lines
2264 bytes
On Sun, 23 Mar 2003 18:15:19 +0100, BigJef wrote:

> How can I insert a new record in an Oracle table with a BLOB field

	Well, I had all kind of trouble to reach that aim. Even today, this is
not pure JDBC, but it's the closer I could manage. My solution is along
these lines :

	- create the item with a null BLOB field
	- "select blobField from myTable for update"
	- get a java.sql.Blob with rs.getBlob (1);
	- get an OutputStream with
		((oracle.sql.BLOB)myBlob).getBinaryOutputStream ();
	- then write in it.

	JDBC-wise (ie, on non-Oracle databases), I use a prepared statement based
on "update myTable set blobField = ?", on which I invoke
setBinaryStream (1, myStream, size); Oracle (8.1.6 here) does nothing
with this construct, alas ... Works perfectly with all other DMBSes I tested
(CachοΏ½, PostgreSQL, Informix, DB2)

	One advantage of this solution : it works with the thin drivers.

	HTH. Feel free to contact me for more info if you wish.
-- 
_Olivier_
Technical Details
Message-ID: <pan.2003.03.24.14.16.52.336024.2159@pcaway.com>
Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!newsfeed.stanford.edu!news-spur1.maxwell.syr.edu!news.maxwell.syr.edu!newsfeed.icl.net!newsfeed.fjserv.net!feed.news.nacamar.de!fu-berlin.de!uni-berlin.de!195.75.28.18!not-for-mail
References: <HYlfa.3434$t_2.317@afrodite.telenet-ops.be>

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII
X-Google-Thread: 107d46,e8c23f2579c7b93f
X-Google-Attributes: gid107d46,public
X-Google-Thread: 10a146,e8c23f2579c7b93f
X-Google-Attributes: gid10a146,public
X-Google-Thread: fcea4,e8c23f2579c7b93f
X-Google-Attributes: gidfcea4,public
X-Google-ArrivalTime: 2003-03-24 06:16:55 PST
Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!newsfeed.stanford.edu!news-spur1.maxwell.syr.edu!news.maxwell.syr.edu!newsfeed.icl.net!newsfeed.fjserv.net!feed.news.nacamar.de!fu-berlin.de!uni-berlin.de!195.75.28.18!not-for-mail
From: Olivier Jousselin <oj@pcaway.com>
Newsgroups: comp.lang.java.databases,comp.lang.java.programmer,be.comp.programming
Subject: Re: Inserting a BLOB into an Oracle BLOB field.
Followup-To: comp.lang.java.databases
Date: Mon, 24 Mar 2003 15:16:52 +0100
Organization: PCAway
Lines: 26
Message-ID: <pan.2003.03.24.14.16.52.336024.2159@pcaway.com>
References: <HYlfa.3434$t_2.317@afrodite.telenet-ops.be>
NNTP-Posting-Host: 195.75.28.18
Mime-Version: 1.0
Content-Type: text/plain; charset=iso-8859-1
Content-Transfer-Encoding: 8bit
X-Trace: fu-berlin.de 1048515413 78760491 195.75.28.18 (16 [177410])
X-Orig-Path: not-for-mail
User-Agent: Pan/0.11.4 (Unix)
X-Comment-To: "BigJef" <tmp-05@pandora.be>