rmoptions - Remove JDBC or ODBC connection options - MATLAB (original) (raw)

Main Content

Remove JDBC or ODBC connection options

Since R2020b

Syntax

Description

Examples

collapse all

Edit an existing JDBC data source for a Microsoft® SQL Server® database. Set an additional JDBC driver-specific option, and test the database connection. Then, remove the additional JDBC driver-specific option, and test and save the data source.

Retrieve the existing SQL Server data source SQLServerDataSource.

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

opts = SQLConnectionOptions with properties:

          DataSourceName: "SQLServerDataSource"
                  Vendor: "Microsoft SQL Server"

      JDBCDriverLocation: "C:\Drivers\mssql-jdbc-7.0.0.jre8.jar"
            DatabaseName: "toystore_doc"
                  Server: "dbtb04"
              PortNumber: 54317
      AuthenticationType: "Windows"

opts is an SQLConnectionOptions object with these properties:

Add a JDBC 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 JDBC connection option.

opts = setoptions(opts,'loginTimeout',"20")

opts = SQLConnectionOptions with properties:

          DataSourceName: "SQLServerDataSource"
                  Vendor: "Microsoft SQL Server"

      JDBCDriverLocation: "C:\Drivers\mssql-jdbc-7.0.0.jre8.jar"
            DatabaseName: "toystore_doc"
                  Server: "dbtb04"
              PortNumber: 54317
      AuthenticationType: "Windows"

Additional Connection Options:

            loginTimeout: "20"

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

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

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

opts = rmoptions(opts,'loginTimeout')

opts = SQLConnectionOptions with properties:

          DataSourceName: "SQLServerDataSource"
                  Vendor: "Microsoft SQL Server"

      JDBCDriverLocation: "C:\Drivers\mssql-jdbc-7.0.0.jre8.jar"
            DatabaseName: "toystore_doc"
                  Server: "dbtb04"
              PortNumber: 54317
      AuthenticationType: "Windows"

Test the database connection again.

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

Save the data source.

Input Arguments

collapse all

Connection option for your JDBC or ODBC connection, specified as a character vector, string scalar, cell array of character vectors, or string array. Specify the name of one or more connection options or driver-specific connection options.

Example: ["DatabaseName" "Server" "PortNumber"]

Example: "loginTimeout"

Data Types: char | string | cell

Output Arguments

Version History

Introduced in R2020b

expand all

Remove connection options for ODBC database connections.

See Also

Objects

Functions

Topics