Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Usenet -> c.d.o.server -> Help: How to insert binary data into Oracle via JDBC?

Help: How to insert binary data into Oracle via JDBC?

From: Michael Zhao <mizhao_at_cisco.com>
Date: 1998/08/20
Message-ID: <Pine.SOL.3.96.980820151000.19872A-100000@redale.cisco.com>#1/1

Hi,

I'm trying to insert and get binary data into/from oracle database via JDBC in Java. I have a simple table and a stored procedure for insert, use normal JDBC api to get data.

Anyone knows how to insert/get BINNARY data by using JDBC? Hex code as in 1 & 2 below, or uuencode is not what I want.

It seems that no method can handle '\0' in binary data.

Any suggestion is highly appreciated.

-Michael



My_tab (
Id	number(5,0);
Data	long;

)

Stored procedure myinsert(id in integer, dat in varchar2 ( or long) )

I tried following methods in java.sql.PreparedStatement to insert binary data, none worked:

i.e.
byte[] mydate={ 'A','B','\0','C','D'};

  1. setBinaryStream(int, InputStream, int)

problem: "AB" become "4142" in db.

2. setBytes(int, byte[])

problem: Same as 1.

3. setAsciiStream(int, InputStream, int)

problem: Only "AB" was inserted into db.

4. setString(int, String)
str = new String(mydata)
setString(2,str);

problem: Same as 1. Received on Thu Aug 20 1998 - 00:00:00 CDT

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US