Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
![]() |
![]() |
Home -> Community -> Usenet -> c.d.o.server -> Help: How to insert binary data into Oracle via JDBC?
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
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'};
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
![]() |
![]() |