Reputation: 41
This is what I am trying to do:
My table looks like this:
TECHID NOT NULL NUMBER(12)
MEDIADATA NOT NULL BLOB()
INSERTEDDATE NOT NULL DATE
MODIFIEDDATE NOT NULL DATE
Steps 1 and 2 work perfectly. The code for step 3 is as follows (this is a PoC type spike solution - not final production):
File resized = get the resized image FileInputStream fis = new FileInputStream(resized) PreparedStatement p = db.connection.prepareStatement("update mymediadata set mediadata = ? where TECHID=142") if (fis != null) { println("Available: ${fis.available()}"); // this works - shows 117K bytes available. } p.setBinaryStream (1, fis, resized?.length()?.intValue()) try { p.executeUpdate() } catch (Exception e) { e.printStackTrace() } finally { p.close() fis.close() }
When I get to step 3, I get the following error:
SQLException: ORA-01407: cannot update ("OWNER"."MEDIADATA"."MEDIADATA") to NULL
I explicitly checked (in debugger) that the FileInputStream (fis) is not null. I also checked that the resized?.length()?.intValue()
value is also > 0. So I am struggling to see what I might be doing wrong.
Technology stack:
Groovy GDK 1.7 Java 1.5 Oracle 10g
Running on 32 bit Windows XP.
Upvotes: 0
Views: 1197
Reputation: 41
OK, I finally managed to resolve this. It turns out it was a dodgy JDBC oracle driver (apparently an earlier version) which was causing the errors.
As soon as I switched to the proper version, the error vanished!
Upvotes: 1