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

[ADO.NET] There should be an exception when server/user/password is not specified in the connection string

    Details

    • Type: Bug
    • Status: Resolved
    • Priority: Minor
    • Resolution: Fixed
    • Affects Version/s: ADONET-8.4.3, ADONET-9.1.0
    • Fix Version/s: ADO.NET 9.2.0.0001
    • Component/s: ADO.NET
    • Labels:

      Description

      According to CUBRID manual at http://www.cubrid.org/manual/90/en/ADO.NET%20Programming, in connection string, all parameters are mandatory except for port.
      There should be an exception when server/user/password is not specified in the connection string, just like the CUBRIDException which is thrown when the database name is missed in the connection string.

        Activity

        Hide
        cn15800 谢韦华[Bert] added a comment -

        Password is optional, not mandatory. So when server/user is null, driver will throw exception.

        Show
        cn15800 谢韦华[Bert] added a comment - Password is optional, not mandatory. So when server/user is null, driver will throw exception.
        Hide
        ryin005 Ray Yin added a comment - - edited

        The exceptions are not consistent between when server/user is not specified and when database is not specified

        Case 1. When database is not sepecified or the connection string is null, the exception would be thrown when conn.ConnectionString called, and the error messages are accurate - Correct

        CUBRIDConnection conn = new CUBRIDConnection();
        
        // database is not specified
        try
        {
            conn.ConnectionString = "server=xx.xx.xx.xx;port=33000;user=dba;password=";
        }
        catch (Exception ex)
        {
            Console.WriteLine("1. " + ex.Message);
        }
        
        // ConnectionString is null
        try
        {
            conn.ConnectionString = null;
        }
        catch (Exception ex)
        {
            Console.WriteLine("2. " + ex.Message);
        }
        

        output

        1. The database name can't be empty!
        2. Connection string is null!: Closed.
        

        Case 2. However, if the server (mandatory) is not specified, the exception would be thrown when conn.Open() called, and error message is not accurate - Incorrect

        CUBRIDConnection conn = new CUBRIDConnection();
        
        // server is not specified
        try
        {
            conn.ConnectionString = "database=demodb;port=33000;user=dba;password=";
            conn.Open();
        }
        catch (Exception ex)
        {
            Console.WriteLine("1. " + ex.Message);
        }
        

        Output

        1. 由于目标计算机积极拒绝,无法连接。 127.0.0.1:33000
        

        Case 3. If the user (mandatory) is not specified, not exception will be thrown, the connection is opened successfully - Incorrect

        CUBRIDConnection conn = new CUBRIDConnection();
        
        // user is not specified
        try
        {
            conn.ConnectionString = "server=xx.xx.xx.xx;database=demodb;port=33000;password=";
            conn.Open();
        }
        catch (Exception ex)
        {
            Console.WriteLine("1. " + ex.Message);
        }
        
        conn.Close();
        
        

        Output:

        No exception thrown
        The Connection is opened
        

        Summary: Case2 & Case3 are incorrect, we should make a consistent exception thrown when server/user/database is not specified on the connection string, or connection string is null. The exception should be thrown when conn.ConnectionString called

        Reopen the issue

        Show
        ryin005 Ray Yin added a comment - - edited The exceptions are not consistent between when server/user is not specified and when database is not specified Case 1. When database is not sepecified or the connection string is null, the exception would be thrown when conn.ConnectionString called, and the error messages are accurate - Correct CUBRIDConnection conn = new CUBRIDConnection(); // database is not specified try { conn.ConnectionString = "server=xx.xx.xx.xx;port=33000;user=dba;password="; } catch (Exception ex) { Console.WriteLine("1. " + ex.Message); } // ConnectionString is null try { conn.ConnectionString = null; } catch (Exception ex) { Console.WriteLine("2. " + ex.Message); } output 1. The database name can't be empty! 2. Connection string is null!: Closed. Case 2. However, if the server (mandatory) is not specified, the exception would be thrown when conn.Open() called, and error message is not accurate - Incorrect CUBRIDConnection conn = new CUBRIDConnection(); // server is not specified try { conn.ConnectionString = "database=demodb;port=33000;user=dba;password="; conn.Open(); } catch (Exception ex) { Console.WriteLine("1. " + ex.Message); } Output 1. 由于目标计算机积极拒绝,无法连接。 127.0.0.1:33000 Case 3. If the user (mandatory) is not specified, not exception will be thrown, the connection is opened successfully - Incorrect CUBRIDConnection conn = new CUBRIDConnection(); // user is not specified try { conn.ConnectionString = "server=xx.xx.xx.xx;database=demodb;port=33000;password="; conn.Open(); } catch (Exception ex) { Console.WriteLine("1. " + ex.Message); } conn.Close(); Output: No exception thrown The Connection is opened Summary: Case2 & Case3 are incorrect, we should make a consistent exception thrown when server/user/database is not specified on the connection string, or connection string is null. The exception should be thrown when conn.ConnectionString called Reopen the issue
        Hide
        cn15800 谢韦华[Bert] added a comment -

        User and server have default value, we can set the default value as null

        Show
        cn15800 谢韦华[Bert] added a comment - User and server have default value, we can set the default value as null
        Hide
        ryin005 Ray Yin added a comment -
        • Test OS: Win32
        • CUBRID: 9.2.0.0149
        • Driver: cubrid-ado.net 9.2.0.0002 (20130916)
        • Framework: .NET 4.0

        Test Result: Pass

        Show
        ryin005 Ray Yin added a comment - Test OS: Win32 CUBRID: 9.2.0.0149 Driver: cubrid-ado.net 9.2.0.0002 (20130916) Framework: .NET 4.0 Test Result: Pass

          People

          • Assignee:
            cn15800 谢韦华[Bert]
            Reporter:
            cn15701 cuiman
          • Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved: