From mboxrd@z Thu Jan 1 00:00:00 1970 Message-ID: <96079334819135.tru64-unix-managers.marc@archive.invalid> From: Lars Bro Date: Mon, 31 Jan 2000 09:04:46 +0000 To: tru64-unix-managers Subject: Strange Java problem X-MARC-Message: https://marc.info/?l=tru64-unix-managers&m=96079334819135 MIME-Version: 1 Content-Type: multipart/mixed; boundary="------=_NextPart_000_0005_01BF6BD2.9B0714E0" This is a multi-part message in MIME format. ------=_NextPart_000_0005_01BF6BD2.9B0714E0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit Hi, Below is a description of a JDBC problem that causes Java programs to fail on T64 4.0F although they worked on T64 4.0D. Have any of you met this problem ? Yours, Lars Bro -----Original Message----- From: Lars Bro [mailto:lbr] Sent: Friday, January 28, 2000 3:16 PM To: 'support_rdbms@dk.oracle.com' Subject: 122808 Hej, her er lidt dok... Systemet er Tru64Unix 4.0f -----Original Message----- From: Arne Christensen [mailto:ach@nettest.dk] Sent: Friday, January 28, 2000 2:49 PM To: lbr Subject: Oracle-fejl A Java application accessing Oracle via JDBC fails when run on Tru64 Unix 4.0F, but not on earlier versions. We use Oracle8 Enterprise Edition Release 8.0.5.0.0 and Thin JDBC driver version 8.0.4.something or 8.0.5.0.0 (does not affect the result). The JDK in use is version 1.1.7B-2. The Java application uses placeholders ("?") in SQL queries and the setInt/setString methods to supply values for these placeholders. It turns out that on Tru64 Unix 4.0F, the setString method delivers its value to the wrong placeholder or not at all, whereas on previous version of the operating system, everything works fine. The same versions of Oracle, JDBC driver and JDK were used in both configurations. The attached small Java program was used to pinpoint the problem. Its results are consistent with the faulty behaviour that our application exhibits. The Java program simply does a SELECT ?, ?, ? FROM DUAL, supplying a varying number of string and integer values for the placeholders, and displays whatever the JDBC driver returns. The results are surprising; a number of examples are also attached. ------=_NextPart_000_0005_01BF6BD2.9B0714E0 Content-Type: application/octet-stream; name="tt.java" Content-Transfer-Encoding: quoted-printable Content-Disposition: attachment; filename="tt.java" import java.sql.*; class tt { public static final String connectionString =3D = "jdbc:oracle:thin:@eir:1521:eir"; public static final String username =3D "qcms"; public static final String password =3D "qcms"; public static void isolateTransactions(Connection conn) throws = SQLException { PreparedStatement st =3D conn.prepareStatement("ALTER SESSION SET = ISOLATION_LEVEL =3D SERIALIZABLE"); st.executeUpdate(); st.close(); } public static void main(String[] args) { String spec =3D args[0]; try { System.out.println("Installing JDBC driver"); Class.forName("oracle.jdbc.driver.OracleDriver"); System.out.println("Logging in to " + connectionString + " = as " + username + "/" + password); Connection conn =3D DriverManager.getConnection(connectionString, = username, password); isolateTransactions(conn); conn.setAutoCommit(false); String sql =3D "SELECT ?"; for (int i =3D 1; i < spec.length(); i++) sql +=3D ", ?"; sql +=3D " FROM DUAL"; System.out.println("Defining query: " + sql); PreparedStatement st =3D conn.prepareStatement(sql); for (int i =3D 0; i < spec.length(); i++) { if (spec.charAt(i) =3D=3D 'n') { System.out.println(" with " + (1000+i+1)); st.setInt(i+1, 1000+i+1); } else { System.out.println(" with string " + (i+1)); st.setString(i+1, "string " + (i+1)); } } System.out.println("Executing query"); ResultSet r =3D st.executeQuery(); while (r.next()) { System.out.println("Returning " + r.getString(1)); for (int i =3D 1; i < spec.length(); i++) System.out.println(" and " + r.getString(i+1)); } System.out.println("Closing query"); st.close(); System.out.println("Closing JDBC connection"); conn.close(); System.out.println("All done"); } catch (SQLException e) { System.out.println("SQLException caught: " + = e.getMessage()); e.printStackTrace(); System.exit(1); } catch (ClassNotFoundException e) { System.out.println("ClassNotFoundException caught: " + = e.getMessage()); e.printStackTrace(); System.exit(1); } } } ------=_NextPart_000_0005_01BF6BD2.9B0714E0 Content-Type: application/octet-stream; name="tt output.dat" Content-Transfer-Encoding: quoted-printable Content-Disposition: attachment; filename="tt output.dat" RESULTS FROM RUNNING THE tt TEST PROGRAM =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D All results were obtained by running command lines like java tt ns The "ns" parameter instructs the program to try one number parameter followed by one string parameter. Login information etc. is found in the start of the program code. Adapt as necessary. One or more numbers work okay ----------------------------- Installing JDBC driver Logging in to jdbc:oracle:thin:@eir:1521:eir as qcms/qcms Defining query: SELECT ? FROM DUAL with 1001 Executing query Returning 1001 Closing query Closing JDBC connection All done Installing JDBC driver Logging in to jdbc:oracle:thin:@eir:1521:eir as qcms/qcms Defining query: SELECT ?, ? FROM DUAL with 1001 with 1002 Executing query Returning 1001 and 1002 Closing query Closing JDBC connection All done One string works okay --------------------- Installing JDBC driver Logging in to jdbc:oracle:thin:@eir:1521:eir as qcms/qcms Defining query: SELECT ? FROM DUAL with string 1 Executing query Returning string 1 Closing query Closing JDBC connection All done More than one string fails -------------------------- Installing JDBC driver Logging in to jdbc:oracle:thin:@eir:1521:eir as qcms/qcms Defining query: SELECT ?, ? FROM DUAL with string 1 with string 2 Executing query Returning string 2 and string 1 Closing query Closing JDBC connection All done Installing JDBC driver Logging in to jdbc:oracle:thin:@eir:1521:eir as qcms/qcms Defining query: SELECT ?, ?, ? FROM DUAL with string 1 with string 2 with string 3 Executing query Returning string 2 and string 3 and string 1 Closing query Closing JDBC connection All done Combinations of numbers and strings fail miserably -------------------------------------------------- Installing JDBC driver Logging in to jdbc:oracle:thin:@eir:1521:eir as qcms/qcms Defining query: SELECT ?, ? FROM DUAL with 1001 with string 2 Executing query Returning 1001 and ?=02 Closing query Closing JDBC connection All done Installing JDBC driver Logging in to jdbc:oracle:thin:@eir:1521:eir as qcms/qcms Defining query: SELECT ?, ? FROM DUAL with string 1 with 1002 Executing query Returning ?=03 and = -0.0000000000000000000000000000000000000000000000000000000000000000000000= 00000000000000000000000000000-15-130-40-90-26949 Closing query Closing JDBC connection All done ------=_NextPart_000_0005_01BF6BD2.9B0714E0--