reset
Reset JDBC or ODBC connection options to defaults
Syntax
Description
resets
all JDBC or ODBC connection options to their default values for all properties, where
opts = reset(opts)opts is one of the following:
SQLConnectionOptionsobject for JDBC connections.SQLConnectionOptionsobject for ODBC connections.
The reset function also removes any additional
driver-specific properties from these objects.
Examples
Create, configure, and test a JDBC data source for a Microsoft® SQL Server® database. Reset the JDBC connection options to their default values. Then configure, test, and save the data source with different JDBC connection options.
Create an SQL Server data source for a JDBC database connection.
vendor = "Microsoft SQL Server"; opts = databaseConnectionOptions("jdbc",vendor)
opts =
SQLConnectionOptions with properties:
DataSourceName: ""
Vendor: "Microsoft SQL Server"
JDBCDriverLocation: ""
DatabaseName: ""
Server: "localhost"
PortNumber: 1433
AuthenticationType: "Server"
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
Configure the data source by setting the JDBC connection options for the data source SQLServerDataSource, full path to the JDBC driver file, database name toystore_doc, database server dbtb04, port number 54317, and Windows® authentication.
opts = setoptions(opts, ... 'DataSourceName',"SQLServerDataSource", ... 'JDBCDriverLocation',"C:\Drivers\mssql-jdbc-7.0.0.jre8.jar", ... 'DatabaseName',"toystore_doc",'Server',"dbtb04", ... 'PortNumber',54317,'AuthenticationType',"Windows")
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"
The setoptions function sets the DataSourceName, JDBCDriverLocation, DatabaseName, Server, PortNumber, and AuthenticationType properties in the SQLConnectionOptions object.
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
Reset the JDBC connection options to their default values. The properties of the SQLConnectionOptions object contain the default values.
opts = reset(opts)
opts =
SQLConnectionOptions with properties:
DataSourceName: ""
Vendor: "Microsoft SQL Server"
JDBCDriverLocation: ""
DatabaseName: ""
Server: "localhost"
PortNumber: 1433
AuthenticationType: "Server"
Configure the data source by setting the JDBC connection options for the data source SQLServerDataSource, full path to the JDBC driver file, database name toystore_doc, database server dbtb04, port number 54317, and Windows® authentication. Also, set driver-specific connection options to specify a timeout value for establishing the database connection, and to disable SSL encryption.
opts = setoptions(opts, ... "DataSourceName","SQLServerDataSource", ... "JDBCDriverLocation", ... "C:\Drivers\mssql-jdbc-7.0.0.jre8.jar", ... "DatabaseName","toystore_doc", ... "Server","dbtb04","PortNumber",54317, ... "AuthenticationType","Windows","loginTimeout","20", ... "encrypt","false")
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:
encrypt: "false"
loginTimeout: "20"
The setoptions function sets the DataSourceName, JDBCDriverLocation, DatabaseName, Server, PortNumber, and AuthenticationType properties in the SQLConnectionOptions object. The driver-specific connection options appear below the other connection options.
Test the database connection again.
username = ""; password = ""; status = testConnection(opts,username,password)
status = logical
1
Save the configured data source.
saveAsDataSource(opts)
Input Arguments
Database connection options, specified as one of the following:
SQLConnectionOptionsobject for JDBC connections.SQLConnectionOptionsobject for ODBC connections.
Output Arguments
Database connection options, returned as one of the following:
SQLConnectionOptionsobject for JDBC connections.SQLConnectionOptionsobject for ODBC connections.
Version History
Introduced in R2020bReset connection options to their default values 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.
Website auswählen
Wählen Sie eine Website aus, um übersetzte Inhalte (sofern verfügbar) sowie lokale Veranstaltungen und Angebote anzuzeigen. Auf der Grundlage Ihres Standorts empfehlen wir Ihnen die folgende Auswahl: .
Sie können auch eine Website aus der folgenden Liste auswählen:
So erhalten Sie die bestmögliche Leistung auf der Website
Wählen Sie für die bestmögliche Website-Leistung die Website für China (auf Chinesisch oder Englisch). Andere landesspezifische Websites von MathWorks sind für Besuche von Ihrem Standort aus nicht optimiert.
Amerika
- América Latina (Español)
- Canada (English)
- United States (English)
Europa
- 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)