Uploaded image for project: 'CUBRID APIs'
  1. CUBRID APIs
  2. APIS-224

Connect function in CUBRIDDriver.java should return null instead of exception

    Details

    • Type: Bug
    • Status: Resolved
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: JDBC 9.0.0
    • Component/s: JDBC
    • Labels:
      None
    • Environment:

      Any

      Description

      In CUBRIDDriver.class in the connect function, this code returns an exception:

      {code:java}
      if (!acceptsURL(paramString)) { throw new CUBRIDException(CUBRIDJDBCErrorCode.invalid_url, paramString); }{code}

      It should return null instead.

      MySQL and PostgreSQL both have:

      {code:java}
      Properties props = null;

      if ((props = parseURL(url, info)) == null) {
      return null;
      }{code}

      or something along that sort.

      I have attached the test code. If you load the CUBRIDDriver (cubrid_jdbc.jar is loaded) and then load a MySQL or any other database (with the driver not being found), then try to connect to connect to the mysql database and it gives a CUBRID error.

      This gives the impression of a bug from CUBRID, when in fact it's caused due to the missing MySQL driver. This was the normal error if the CUBRIDDriver was not loaded:

      {code:java}
      java.sql.SQLException: No suitable driver found for jdbc:mysql://localhost:3306/test
      at java.sql.DriverManager.getConnection(Unknown Source)
      at java.sql.DriverManager.getConnection(Unknown Source)
      at stress.Test.<init>(Test.java:20)
      at stress.Test.main(Test.java:35){code}

      The rule that was broken is that connect function must return "null" if driver url is not recognized:
      http://docs.oracle.com/javase/7/docs/api/java/sql/Driver.html#connect(java.lang.String, java.util.Properties)

      I quote here what the connect function does:
      "Attempts to make a database connection to the given URL. The driver should return "null" if it realizes it is the wrong kind of driver to connect to the given URL. This will be common, as when the JDBC driver manager is asked to connect to a given URL it passes the URL to each loaded driver in turn."

      1. output.txt
        0.3 kB
        Veliscu Ovidiu
      2. Test.java
        0.7 kB
        Veliscu Ovidiu

        Activity

        Show
        kadishmal Esen Sagynov added a comment - Reported to http://bts4.nhncorp.com/nhnbts/browse/CUBRIDSUS-8919 .
        Hide
        kadishmal Esen Sagynov added a comment -

        Ovidiu, in such cases, please mention that a particular user had this issue. In this case, JMyETL developer seem to have encountered this issue.

        Show
        kadishmal Esen Sagynov added a comment - Ovidiu, in such cases, please mention that a particular user had this issue. In this case, JMyETL developer seem to have encountered this issue.
        Hide
        ovidiu.veliscu Veliscu Ovidiu added a comment -

        I know, but that's irrelevant in this case. The CUBRID JDBC driver currently does not respect one of the clear rules for the connect() function, so I'm sure there are other scenarios in which the problem will occur.

        Show
        ovidiu.veliscu Veliscu Ovidiu added a comment - I know, but that's irrelevant in this case. The CUBRID JDBC driver currently does not respect one of the clear rules for the connect() function, so I'm sure there are other scenarios in which the problem will occur.
        Hide
        kadishmal Esen Sagynov added a comment -

        It is relevant, because the fact that actual external user has reported this influences the urgency of the issue.

        Regarding the issue itself, I understand. But I can't guarantee when the issue will be fixed.

        Show
        kadishmal Esen Sagynov added a comment - It is relevant, because the fact that actual external user has reported this influences the urgency of the issue. Regarding the issue itself, I understand. But I can't guarantee when the issue will be fixed.
        Hide
        ovidiu.veliscu Veliscu Ovidiu added a comment -

        Ok, I will mention the application or post the link to the forum/Q&A when I post other issues.

        Show
        ovidiu.veliscu Veliscu Ovidiu added a comment - Ok, I will mention the application or post the link to the forum/Q&A when I post other issues.
        Hide
        kadishmal Esen Sagynov added a comment -

        Approved and assigned. Should be fixed by Apricot release. Will update later.

        Show
        kadishmal Esen Sagynov added a comment - Approved and assigned. Should be fixed by Apricot release. Will update later.
        Hide
        kadishmal Esen Sagynov added a comment -

        Fixed in Apricot.

        Show
        kadishmal Esen Sagynov added a comment - Fixed in Apricot.

          People

          • Assignee:
            kadishmal Esen Sagynov
            Reporter:
            ovidiu.veliscu Veliscu Ovidiu
          • Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved: