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

Home -> Community -> Usenet -> c.d.o.tools -> inserting binary objects with Java

inserting binary objects with Java

From: Tennessee Leeuwenburg <t.leeuwenburg_at_bom.gov.au>
Date: Sun, 14 Jan 2001 23:55:22 GMT
Message-ID: <3a623c5f.266063849@news.bom.gov.au>

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

Original text of this message

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