| Database Toolbox | ![]() |
Set or get time allowed to establish database connection
Syntax
timeout = logintimeout('driver', time)
timeout = logintimeout(time)
timeout = logintimeout('driver')
timeout = logintimeout
Description
timeout = logintimeout('driver', time)
sets the amount of time, in seconds, allowed for a MATLAB session to try to connect to a database via the specified JDBC driver. Use logintimeout before running the database function. If MATLAB cannot connect within the allowed time, it stops trying.
timeout = logintimeout(time)
sets the amount of time, in seconds, allowed for a MATLAB session to try to connect to a database via an ODBC connection. Use logintimeout before running the database function. If MATLAB cannot connect within the allowed time, it stops trying.
timeout = logintimeout('driver')
returns the time, in seconds, you set previously using logintimeout for the JDBC connection specified by driver. A returned value of zero means that the timeout value has not been set previously; MATLAB stops trying to make a connection if it is not immediately successful.
timeout = logintimeout
returns the time, in seconds, you set previously using logintimeout for an ODBC connection. A returned value of zero means that the timeout value has not been set previously; MATLAB stops trying to make a connection if it is not immediately successful.
If you do not use logintimeout and MATLAB tries to connect without success, your MATLAB session could hang up.
Example 1 - Get Timeout Value for ODBC Connection
Your database connection is via an ODBC connection. To see the current timeout value, type
logintimeout
ans =
0
The timeout value has not been set.
Example 2 - Set Timeout Value for ODBC Connection
Set the timeout value to five seconds for an ODBC driver. Type
logintimeout(5)
ans =
5
Example 3 - Get and Set Timeout Value for JDBC Connection
Your database connection is via the Oracle JDBC driver. First see what the current timeout value is. Type
logintimeout('oracle.jdbc.driver.OracleDriver')
ans =
0
The timeout value is currently 0. Set the timeout to 10 seconds. Type
timeout = logintimeout('oracle.jdbc.driver.OracleDriver', 10)
timeout =
10
Verify the timeout value for the JDBC driver. Type
logintimeout('oracle.jdbc.driver.OracleDriver')
ans =
10
| isurl | namecolumn | ![]() |