mariec
asked on
writing Oracle 9 BLOB (JDBC)
Hello all!
I'm having trouble with Oracle Blobs through java. I don't know in which forum I should ask this question, but here goes:
I have an Oracle 9i database and JDBC 9.2 driver version.
I am using java v1.4.
I'm connecting to my database using the following:
DriverManager.registerDriv er(new oracle.jdbc.driver.OracleD river());
_connection = DriverManager.getConnectio n("jdbc:or acle:thin: @host:port :ut", user, passwd);
In my code, i'm trying to write a blob to my table and the code looks like this:
import java.sql.*;
import oracle.sql.BLOB;
...
String sql = "SELECT VALIDITY FROM RANGEEVENT WHERE IDEVENT="+idLREvent;
stmt = Database.getConnection().c reateState ment();
ResultSet rs = stmt.executeQuery(sql);
if (rs.next()) {
Blob myblob = rs.getBlob(1);
OutputStream os = ((BLOB)myblob).setBinarySt ream(0);
os.write(validity);
os.close();
}
BUT i get this error:
java.sql.SQLException: Unsupported function
After debugging, I found that it is "((BLOB)myblob).setBinaryS tream(0);" which is causing this problem.
I've been reading the Oracle JDBC doc and can't find what the problem could be. I tried using OCI driver for connection but then I get ORA-06401: NETCMN error...
I'm having trouble with Oracle Blobs through java. I don't know in which forum I should ask this question, but here goes:
I have an Oracle 9i database and JDBC 9.2 driver version.
I am using java v1.4.
I'm connecting to my database using the following:
DriverManager.registerDriv
_connection = DriverManager.getConnectio
In my code, i'm trying to write a blob to my table and the code looks like this:
import java.sql.*;
import oracle.sql.BLOB;
...
String sql = "SELECT VALIDITY FROM RANGEEVENT WHERE IDEVENT="+idLREvent;
stmt = Database.getConnection().c
ResultSet rs = stmt.executeQuery(sql);
if (rs.next()) {
Blob myblob = rs.getBlob(1);
OutputStream os = ((BLOB)myblob).setBinarySt
os.write(validity);
os.close();
}
BUT i get this error:
java.sql.SQLException: Unsupported function
After debugging, I found that it is "((BLOB)myblob).setBinaryS
I've been reading the Oracle JDBC doc and can't find what the problem could be. I tried using OCI driver for connection but then I get ORA-06401: NETCMN error...
Hi,
you should use DBMS_LOB package to write blob data to database.
regards.
you should use DBMS_LOB package to write blob data to database.
regards.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
grim_toaster's hints helped out alot. Query for update helps as well as disabling autocommit.
Seazodiac, its an interesting article but since the JDBC 2.0 standard is available, the code must be changed a little. Thanks for the doc though.
Seazodiac, its an interesting article but since the JDBC 2.0 standard is available, the code must be changed a little. Thanks for the doc though.
ASKER
OutputStream os = ((BLOB)myblob).getBinaryOu
and it still doesnt work