This is a multi-part message in MIME format.
--------------460810D73136F82438059B26
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit
Hello,
there is a bug in the Oracle Thin JDBC Driver 7.3.4: Streaming of
LONG/LONG RAW in parameters may cause exceptions.
I attached a little Java program to this message which reproduces the
bug and produces the following output:
J:\projects\Test\src\Test>java BLOBBug2
1 rows with data size=512bytes inserted at point 1.1
java.sql.SQLException: ORA-01483: invalid length for DATE or NUMBER bind
variable
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
oracle.jdbc.driver.OracleStatement.doExecuteOther(OracleStatement.java:761)
at at at at BLOBBug2.main(BLOBBug2.java:67) at oracle.jdbc.ttc7.TTIoer.processError(TTIoer.java:184) at at at at at BLOBBug2.main(BLOBBug2.java:93) The same program works fine with the OCI7 driver. Michael Seyfried --------------460810D73136F82438059B26 import java.sql.*; class BLOBBug2 public static void main (String args []) // replace connection parameters for your database conn.setAutoCommit (false); Statement stmt = conn.createStatement (); // Create file with size bytes of data int c; // Create the example table // Insert 1.1 => works fine // Insert 1.2 => throws an exception // Insert 2.1 => works fine // Insert 2.2 => throws an exception
oracle.jdbc.driver.OracleStatement.doExecuteWithBatch(OracleStatement.java:
oracle.jdbc.driver.OracleStatement.doExecute(OracleStatement.java:1145)
at
oracle.jdbc.driver.OracleStatement.doExecuteWithTimeout(OracleStatement.jav
oracle.jdbc.driver.OraclePreparedStatement.executeUpdate(OraclePreparedStat
1 rows with data size=512bytes inserted at point 2.1
java.sql.SQLException: ORA-01483: invalid length for DATE or NUMBER bind
variable
at oracle.jdbc.ttc7.Oall7.receive(Oall7.java:631)
at oracle.jdbc.ttc7.TTC7Protocol.doOall7(TTC7Protocol.java:1206)
oracle.jdbc.ttc7.TTC7Protocol.parseExecuteFetch(TTC7Protocol.java:649)
at
oracle.jdbc.driver.OracleStatement.doExecuteOther(OracleStatement.java:761)
oracle.jdbc.driver.OracleStatement.doExecuteWithBatch(OracleStatement.java:
oracle.jdbc.driver.OracleStatement.doExecute(OracleStatement.java:1145)
at
oracle.jdbc.driver.OracleStatement.doExecuteWithTimeout(OracleStatement.jav
oracle.jdbc.driver.OraclePreparedStatement.executeUpdate(OraclePreparedStat
--------------------------------------------------------------------
BLITZ Internet Service GmbH, Nebingerhof 5, D-96047 Bamberg, Germany
Tel: +49/951/9685163, Fax: +49/951/9685164, http://www.blitz.net
Content-Type: java/*; name="BLOBBug2.java"
Content-Transfer-Encoding: 7bit
Content-Disposition: inline; filename="BLOBBug2.java"
import java.io.*;
{
static final int size = 512;
throws SQLException, ClassNotFoundException, IOException
{
Class.forName ("oracle.jdbc.driver.OracleDriver");
// the error does only occur using jdbc:oracle:thin, jdbc:oracle:oci7 works correct.
Connection conn =
// A. works fine with this connection:
// B. throws exceptions with this connection:
{
FileOutputStream os = new FileOutputStream ("data.dat");
byte buf [] = new byte [size];
os.write (buf);
os.close ();
}
try
{
stmt.execute ("drop table streamexample1");
stmt.execute ("drop table streamexample2");
}
catch (SQLException e)
{
}
stmt.execute ("create table streamexample1 (ID number (10), DATA long raw)");
stmt.execute ("create table streamexample2 (ID number (10), DATA long)");
File file = new File ("data.dat");
InputStream is = new FileInputStream (file);
PreparedStatement pstmt = conn.prepareStatement ("insert into streamexample1 (id, data) values (?, ?)");
try {
pstmt.setInt (1, 1);
pstmt.setBinaryStream (2, is, (int)file.length ());
System.out.println (pstmt.executeUpdate () + " rows with data size=" + file.length () + "bytes inserted at point 1.1");
} catch (SQLException e) {
e.printStackTrace ();
} finally {
is.close ();
}
is = new FileInputStream (file);
pstmt = conn.prepareStatement ("insert into streamexample1 (data, id) values (?, ?)");
try {
pstmt.setBinaryStream (1, is, (int)file.length ());
pstmt.setInt (2, 2);
System.out.println (pstmt.executeUpdate () + " rows with data size=" + file.length () + "bytes inserted at point 1.2");
} catch (SQLException e) {
e.printStackTrace ();
} finally {
is.close ();
}
is = new FileInputStream (file);
pstmt = conn.prepareStatement ("insert into streamexample1 (id, data) values (?, ?)");
try {
pstmt.setInt (1, 1);
pstmt.setBinaryStream (2, is, (int)file.length ());
System.out.println (pstmt.executeUpdate () + " rows with data size=" + file.length () + "bytes inserted at point 2.1");
} catch (SQLException e) {
e.printStackTrace ();
} finally {
is.close ();
}
is = new FileInputStream (file);
pstmt = conn.prepareStatement ("insert into streamexample1 (data, id) values (?, ?)");
try {
pstmt.setBinaryStream (1, is, (int)file.length ());
pstmt.setInt (2, 2);
System.out.println (pstmt.executeUpdate () + " rows with data size=" + file.length () + "bytes inserted at point 2.2");
} catch (SQLException e) {
e.printStackTrace ();
} finally {
is.close ();
}
}
--------------460810D73136F82438059B26--