Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
Home -> Community -> Usenet -> c.d.o.misc -> Oracle JDBC Thin Driver and Long Raw Columns
I am trying to insert a file (image, word processing document, etc) into a long raw column using JDBC 7.3.4 thin drivers. We are using Oracle7 Server Release 7.2.3.0.0. Is it possible to do this with the thin drivers or do I need to use OCI? Is there any secret about JDBC and long raw, because no matter what I do I keep getting the ORA-00932 error? Any hint in the right direction would be greatly appreciated.
Thanks,
Chris O'Shea
Unisys Corporation
christophercoshea_at_unn.unisys.com
ERROR MESSAGE
c:\java>java JdbcTest
java.sql.SQLException: ORA-00932: inconsistent datatypes
at oracle.jdbc.ttc7.TTIoer.processError(TTIoer.java:184) at oracle.jdbc.ttc7.Oall7.receive(Oall7.java:631) at oracle.jdbc.ttc7.TTC7Protocol.doOall7(TTC7Protocol.java:1206) at oracle.jdbc.ttc7.TTC7Protocol.parseExecuteFetch(TTC7Protocol.java:649)at
JAVA CODE
import java.sql.*;
import java.io.*;
import oracle.jdbc.*;
class JdbcTest
{
public static void main (String args [])
throws SQLException, ClassNotFoundException, FileNotFoundException,
IOException
{
// Load the Oracle JDBC driver
Class.forName ("oracle.jdbc.driver.OracleDriver");
// Connect to the database // You must put a database name after the @
sign in the connection URL. // You can use either the fully specified
SQL*net syntax or a short cut // syntax as <host>:<port>:<sid>. The
example uses the short cut syntax. Connection conn =
DriverManager.getConnection
("jdbc:oracle:thin:@psfd.ea.unisys.com:1521:psfd", "userid", "passwd");
// Create a Statement
int len;
String insertStmt = "insert into oshea_test (emplid, ug_document)
values (?,?)";
String emplid = "020425";
String filein = "test.doc";
PreparedStatement stmt = conn.prepareStatement(insertStmt);
File mfile = new File(filein);
len = (int) mfile.length();
InputStream inputStream = new FileInputStream(mfile);
stmt.setString(1, emplid);
stmt.setBinaryStream(2, inputStream, len);
int rows = stmt.executeUpdate();
System.out.println (rows);
}
}
TABLE DESCRIPTION
SQL> desc oshea_Test
Name Null? Type ------------------------------- -------- ---- EMPLID VARCHAR2(11) UG_DOCUMENT LONG RAW -------------------==== Posted via Deja News ====----------------------- http://www.dejanews.com/ Search, Read, Post to UsenetReceived on Mon Feb 02 1998 - 00:00:00 CST