rmoptions - Remove MySQL native interface connection options - MATLAB (original) (raw)

Remove MySQL native interface connection options

Since R2020b

Syntax

Description

Examples

collapse all

Remove Driver-Specific Connection Option

Edit an existing MySQL® native interface data source for a MySQL database. Set an additional driver-specific option, and test the database connection. Then, remove the additional driver-specific option, and test and save the data source.

Retrieve the existing MySQL native interface data source.

datasource = "MySQLDataSource"; opts = databaseConnectionOptions(datasource)

opts = SQLConnectionOptions with properties:

          DataSourceName: "MySQLDataSource"
                  Vendor: "MySQL"

            DatabaseName: "toystore_doc"
                  Server: "dbtb01"
              PortNumber: 3306

opts is an SQLConnectionOptions object with these properties:

Add a driver-specific connection option by using a name-value pair argument. The option specifies a timeout value for establishing the database connection. opts contains a new property for the additional connection option.

opts = setoptions(opts,"OPT_CONNECT_TIMEOUT",20)

opts = SQLConnectionOptions with properties:

          DataSourceName: "MySQLDataSource"
                  Vendor: "MySQL"

            DatabaseName: "toystore_doc"
                  Server: "dbtb01"
              PortNumber: 3306

Additional Connection Options:

     OPT_CONNECT_TIMEOUT: 20

Test the database connection with a user name and password. The testConnection function returns the logical 1, which indicates the database connection is successful.

username = "root"; password = "matlab"; status = testConnection(opts,username,password)

Remove the driver-specific option for specifying a timeout value. The opts object no longer contains the OPT_CONNECT_TIMEOUT property.

opts = rmoptions(opts,"OPT_CONNECT_TIMEOUT")

opts = SQLConnectionOptions with properties:

          DataSourceName: "MySQLDataSource"
                  Vendor: "MySQL"

            DatabaseName: "toystore_doc"
                  Server: "dbtb01"
              PortNumber: 3306

Test the database connection again.

username = "root"; password = "matlab"; status = testConnection(opts,username,password)

Save the data source.

Input Arguments

collapse all

opts — Database connection options

SQLConnectionOptions object

Database connection options, specified as an SQLConnectionOptions object.

option — MySQL® native interface connection option

character vector | string scalar | cell array of character vectors | string array

MySQL native interface connection option, specified as a character vector, string scalar, cell array of character vectors, or string array. Specify the name of one or more MySQL native interface connection options or driver-specific connection options.

Example: ["sslCert" "OPT_RECONNECT"]

Example: "OPT_CONNECT_TIMEOUT"

Data Types: char | string | cell

Output Arguments

collapse all

opts — Database connection options

SQLConnectionOptions object

Database connection options, returned as an SQLConnectionOptions object.

Version History

Introduced in R2020b

See Also

Objects

Functions

Topics