Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
![]() |
![]() |
Home -> Community -> Usenet -> c.d.o.misc -> Bug in JDBC??? Can't be!!!
I think I've come across a bug in oracles JDBC. The problem is it's so
basic I can't believe it. Could anyone please confirm it or say what I'm
doing wrong?
I have recently installed JDBC from the Oracle 8.0.5 CD and am accessing an 8.0.5 database.
I copied some example code given by Thomas Kite from a previous thread which I amended slightly to access my database. It worked fine using the OCI driver. I then ran it using the thin driver and it produced different results!! The problem seems to be that the statement :
INSERT into test2 (colx,coly) values(?,?) inserts correctly using OCI driver but the two parameters get transposed when using the thin driver!!!!!
So the program produces :
1 rows inserted, 4 updated (where the number updatedgoes up by one each time I run the program)
but when using the thin driver I get
1 rows inserted, 0 updated
Example data
COLX COLY
---------- ----------
a b mike burden test8 test8 test1 test3 test1 test3 test1 test3 test1 test3 test1 test3 (e.g. of using oci) test2 test1 (e.g. of using thin) test2 test1 test1 test3 test2 test1 test2 test1 test1 test3
14 rows selected.
The problem is that this bug is so basic I'm not sure whether I can trust JDBC.
Example code follows....thank you for your time.
import java.sql.*;
class UpdateTest {
public static void main (String args []) throws SQLException {
System.out.println ( " Program Started" );
DriverManager.registerDriver (new
oracle.jdbc.driver.OracleDriver());
Connection conn =
// DriverManager.getConnection ("jdbc:oracle:oci8:@PO8.WORLD",
// DriverManager.getConnection
("jdbc:oracle:oci8:@description=(address=(host=vulcan)(protocol=tcp)(port=1521))(connect_data=(sid=PO8)))",
// DriverManager.getConnection ("jdbc:oracle:oci8:@vulcan:1521:PO8",
DriverManager.getConnection ("jdbc:oracle:thin:@vulcan:1521:PO8", "poowner", "poowner"); PreparedStatement ps = conn.prepareStatement( "insert into test2 (colx,coly) values ( ?,? )" );
ps.setString( 1, "test1" );
ps.setString( 2, "test2" );
int rows1 = ps.executeUpdate();
ps.close();
ps = conn.prepareStatement(
"update test2 set coly = ? where colx = ?" );
ps.setString( 1, "test3" );
ps.setString( 2, "test1" );
int rows2 = ps.executeUpdate();
ps.close();
System.out.println ( rows1 + " rows inserted, " + rows2 + " updated" );
} Received on Mon Mar 15 1999 - 10:43:47 CST
![]() |
![]() |