rmoptions
Description
removes JDBC or ODBC connection options, where opts
= rmoptions(opts
,option
)opts
is one of the following:
SQLConnectionOptions
object for JDBC connections.SQLConnectionOptions
object for ODBC connections.
Examples
Remove Driver-Specific Connection Option
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:
DataSourceName
— Name of the data sourceVendor
— Database vendor nameJDBCDriverLocation
— Full path of the JDBC driver fileDatabaseName
— Name of the databaseServer
— Name of the database serverPortNumber
— Port numberAuthenticationType
— Authentication type
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)
status = logical
1
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)
status = logical
1
Save the data source.
saveAsDataSource(opts)
Input Arguments
opts
— Database connection options
SQLConnectionOptions
object
Database connection options, specified as one of the following:
SQLConnectionOptions
object for JDBC connections.SQLConnectionOptions
object for ODBC connections.
option
— Connection option
character vector | string scalar | cell array of character vectors | string array
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
opts
— Database connection options
SQLConnectionOptions
object
Database connection options, returned as one of the following:
SQLConnectionOptions
object for JDBC connections.SQLConnectionOptions
object for ODBC connections.
Version History
Introduced in R2020bR2024a: Remove ODBC connection options
Remove connection options for ODBC database connections.
See Also
Objects
Functions
MATLAB Command
You clicked a link that corresponds to this MATLAB command:
Run the command by entering it in the MATLAB Command Window. Web browsers do not support MATLAB commands.
Select a Web Site
Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select: .
You can also select a web site from the following list:
How to Get Best Site Performance
Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.
Americas
- América Latina (Español)
- Canada (English)
- United States (English)
Europe
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)