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

javax.sql.DataSource should not register itself with the DriverManager

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed
    • Priority: P5
    • Resolution: Future Project
    • Affects Version/s: 6
    • Fix Version/s: None
    • Component/s: core-libs
    • Labels:

      Description

      FULL PRODUCT VERSION :
      C:\Programme\Java\jdk1.6.0\bin>java -version
      java version "1.6.0"
      Java(TM) SE Runtime Environment (build 1.6.0-b105)
      Java HotSpot(TM) Client VM (build 1.6.0-b105, mixed mode)


      ADDITIONAL OS VERSION INFORMATION :
      Windows XP prof. SP-2

      A DESCRIPTION OF THE PROBLEM :
      In the javadoc of javax.sql.DataSource is written:
      A driver that is accessed via a DataSource object does not register itself with the DriverManager.

      The current implementation of Java 6.0 of sun.jdbc.odbc.ee.DataSource does not fulfil this directive.


      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      Instantiate an sun.jdbc.odbc.ee.DataSource object, and invoke method getConnection() .

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      A driver that is accessed via a DataSource object should not register itself with the DriverManager.
      ACTUAL -
      Invoking of 'new JdbcOdbcDriver()' automatically registers the driver with the DriverManager.
      See source code below ...

      REPRODUCIBILITY :
      This bug can be reproduced always.

      ---------- BEGIN SOURCE ----------
      See the part of the source code of class sun.jdbc.odbc.ee.DataSource:

          public Connection getConnection() throws SQLException{
           attrib = super.getAttributes();
           JdbcOdbcDriver driver = new JdbcOdbcDriver();
           driver.setTimeOut(super.getLoginTimeout());
           driver.setWriter(super.getLogWriter());
        return driver.connect(attrib.getUrl(),attrib.getProperties());
          }

      Invoking of 'new JdbcOdbcDriver()' automatically registers the driver with the DriverManager.

      The source code should be something like this:

          public Connection getConnection() throws SQLException {
              // Load our ODBC API object allocate the environment handle,
              // create the connection object and connect it.
              return new JdbcOdbcConnection(getOdbcApi().initialize()).initialize(getConnectProperties());
          }


      ---------- END SOURCE ----------

      CUSTOMER SUBMITTED WORKAROUND :
      Use: https://jdbc-odbc-enhanced.dev.java.net

        Attachments

          Activity

            People

            Assignee:
            lancea Lance Andersen
            Reporter:
            ryeung Roger Yeung (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Dates

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: