| Database Toolbox User's Guide | Search  Help Desk |
| logintimeout | Examples See Also |
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 database. 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 database. If MATLAB cannot connect within the allowed time, it stops trying.
timeout = logintimeout('driver')
returns the time 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 successful immediately.
timeout = logintimeout
returns the time 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 successful immediately.
If you do not use logintimeout and MATLAB tries to connect without success, your MATLAB session could hang up.
Examples
Example 1 - Get timeout value for ODBC connection
Your database connection is via an ODBC connection. To see the current timeout value, type:logintimeoutMATLAB returns:
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: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:logintimeout('oracle.jdbc.driver.OracleDriver')
ans =
0
The timeout value has not been set. Set the timeout to 10 seconds:
timeoutA = logintimeout('oracle.jdbc.driver.OracleDriver', 10)
timeoutA =
10
Verify the timeout value for the JDBC driver:
timeoutAMATAB returns:
timeoutA =
10
See Also
database