Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
![]() |
![]() |
Home -> Community -> Usenet -> c.d.o.tools -> inserting binary objects with Java
Hi all,
not doubt a common question, but one that's stumping me! I'm trying to insert some binary data (actually a gif file) into an Oracle database using jdbc. I've gotten the data into a byte[] array, and I'm using a PreparedStatement.
String query = ("insert into " + insert_table + " (" + key_item + ", " + insert_item + ") values ( " + iN.toString() + ", ? )"); putPhoto(query, fileBytes); static void putPhoto(String query, byte[] b) { try { Connection conn = DriverManager.getConnection ("jdbc:oracle:thin:%%%%", "%%", "%%"); System.err.println(query); PreparedStatement stmt = conn.prepareStatement(query); stmt.setBytes(0, b); int status = stmt.executeUpdate(query); return; } catch(SQLException f) { printSQLErrors(f); } return; }
The error I'm getting is "Invalid Column Index. I'm fairly sure that the error is referring to the byte array, not the key value. iN is an Integer containing the index.
Can anyone help, or can anyone point out any examples of queries to insert binary data into an Oracle database?
Thanks heaps,
-Tennessee Received on Sun Jan 14 2001 - 17:55:22 CST
![]() |
![]() |