Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-4361008

JdbcOdbc 32-64 bit problems

XMLWordPrintable

    • beta3
    • generic
    • generic

      daniel.indrigo@canada 2000-08-09

      There is a 32-64 bit problem with JdbcOdbc support that we would like to see
      fixed in J2SDK 1.3.1. Many of the hEnv, hDbc, and hStmt parameters that are
      passed to native methods, such as Java_sun_jdbc_odbc_JdbcOdbc_cancel(), are
      used
      to store addresses. These parameters are incorrectly declared as jint's
      when
      they should be jlong's. Type jint is too small to store an address on 64
      bit
      systems (such as Alpha).

      Note that changing the signature of native methods in JdbcOdbc.c also
      requires
      changes in the Java classes that define and use these methods and changes to
      the declarations of the hEnv, hDbc, and hStmt fields. Here is a list of
      files
      that we have had to change:

              src/share/classes/sun/jdbc/odbc/JdbcOdbcDatabaseMetaData.java
              src/share/classes/sun/jdbc/odbc/JdbcOdbcResultSetMetaData.java
              src/share/classes/sun/jdbc/odbc/JdbcOdbc.c
              src/share/classes/sun/jdbc/odbc/JdbcOdbc.java
              src/share/classes/sun/jdbc/odbc/JdbcOdbcConnection.java
              src/share/classes/sun/jdbc/odbc/JdbcOdbcConnectionInterface.java
              src/share/classes/sun/jdbc/odbc/JdbcOdbcDriver.java
              src/share/classes/sun/jdbc/odbc/JdbcOdbcDriverInterface.java
              src/share/classes/sun/jdbc/odbc/JdbcOdbcInputStream.java
              src/share/classes/sun/jdbc/odbc/JdbcOdbcResultSet.java
              src/share/classes/sun/jdbc/odbc/JdbcOdbcResultSetInterface.java
              src/share/classes/sun/jdbc/odbc/JdbcOdbcStatement.java

      Another 32-64 bit problem with JdbcOdbc involves the use of the pBuf,
      gDataBuf,
      and other buffers in JdbcOdbc.c. For example, in the following code in
      module
      src/share/classes/sun/jdbc/odbc/JdbcOdbc.c, pBuf and gDatabuf get cast to
      int's even though they contain addresses. They should be cast to longs, and
      array pBuffers should be declared as an array of longs. Note that like the
      above change, this affects not only many functions in JdbcOdbc.c, but also
      some
      of the JdbcOdbc .java files.

              jobject gDataBuf = (*env)->NewGlobalRef(env, dataBuf);
              jobject glenInd = (*env)->NewGlobalRef(env, lenInd);

              // Get the buffer for the column's data. In this case, we'll set it
              // to the column number. This number will be returned by
      SQLParamData.
              // It is assumed that this buffer is large enough to fit a 4-byte
      integer.

              if (dataBuf != NULL) {

                      pBuf = (UCHAR*) (*env)->GetByteArrayElements(env, gDataBuf,
      0);
                      lBuf = (SDWORD) (*env)->GetArrayLength(env, gDataBuf);

                      memset (pBuf, 0x00, lBuf);

                      memcpy (pBuf, &icol, lBuf);
                      // Make a copy of the incoming value
                      //memcpy (pBuf + (sizeof(int) * icol), &icol, sizeof(icol));

                      pBuffers[0]=(int)pBuf; //Store the pointers
                      pBuffers[1]=(int)gDataBuf;
              }

            bpg Binod Pankajakshy Gangadharan (Inactive)
            dindrigo Daniel Indrigo (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: