reset
Syntax
Description
resets
all connection options to their default values for all properties of the opts
= reset(opts
)SQLConnectionOptions
object. The reset
function also
removes any additional driver-specific properties from the
SQLConnectionOptions
object.
Examples
Reset Connection Options to Default Values
Create, configure, and test a PostgreSQL native interface data source for a PostgreSQL database. Reset the database connection options to their default values. Then configure, test, and save the data source with different database connection options.
Create a PostgreSQL native interface data source for a PostgreSQL database connection.
vendor = "PostgreSQL"; opts = databaseConnectionOptions("native",vendor)
opts = SQLConnectionOptions with properties: DataSourceName: "" Vendor: "PostgreSQL" DatabaseName: "" Server: "localhost" PortNumber: 5432
opts
is an SQLConnectionOptions
object with these properties:
DataSourceName
— Name of the data sourceVendor
— Database vendor nameDatabaseName
— Name of the databaseServer
— Name of the database serverPortNumber
— Port number
Configure the data source by setting the database connection options for the data source PostgreSQLDataSource
, database name toystore_doc
, database server dbtb00
, and port number 5432
.
opts = setoptions(opts, ... 'DataSourceName',"PostgreSQLDataSource", ... 'DatabaseName',"toystore_doc",'Server',"dbtb00", ... 'PortNumber',5432)
opts = SQLConnectionOptions with properties: DataSourceName: "PostgreSQLDataSource" Vendor: "PostgreSQL" DatabaseName: "toystore_doc" Server: "dbtb00" PortNumber: 5432
The setoptions
function sets the DataSourceName
, DatabaseName
, Server
, and PortNumber
properties in the SQLConnectionOptions
object.
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 = "dbdev"; password = "matlab"; status = testConnection(opts,username,password)
status = logical
1
Reset the database connection options to their default values.
opts = reset(opts)
opts = SQLConnectionOptions with properties: DataSourceName: "" Vendor: "PostgreSQL" DatabaseName: "" Server: "localhost" PortNumber: 5432
Configure the data source again by setting the database connection options for the data source PostgreSQLDataSource
, database name toystore_doc
, database server dbtb00
, and port number 5432
. Also, set a driver-specific connection option to specify a timeout value for establishing the database connection.
opts = setoptions(opts, ... "DataSourceName","PostgreSQLDataSource", ... "DatabaseName","toystore_doc", ... "Server","dbtb00","PortNumber",5432, ... "connect_timeout",20)
opts = SQLConnectionOptions with properties: DataSourceName: "PostgreSQLDataSource" Vendor: "PostgreSQL" DatabaseName: "toystore_doc" Server: "dbtb00" PortNumber: 5432 Additional Connection Options: connect_timeout: 20
The setoptions
function sets the DataSourceName
, DatabaseName
, Server
, and PortNumber
properties in the SQLConnectionOptions
object. The driver-specific connection option appears below the other connection options.
Test the database connection again.
username = "dbdev"; password = "matlab"; status = testConnection(opts,username,password)
status = logical
1
Save the configured data source.
saveAsDataSource(opts)
Input Arguments
opts
— Database connection options
SQLConnectionOptions
object
Database connection options, specified as an SQLConnectionOptions
object.
Output Arguments
opts
— Database connection options
SQLConnectionOptions
object
Database connection options, returned as an SQLConnectionOptions
object.
Version History
Introduced in R2020b
Comando MATLAB
Hai fatto clic su un collegamento che corrisponde a questo comando MATLAB:
Esegui il comando inserendolo nella finestra di comando MATLAB. I browser web non supportano i comandi MATLAB.
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)