Documentation

This is machine translation

Translated by Microsoft
Mouseover text to see original. Click the button below to return to the English verison of the page.

Note: This page has been translated by MathWorks. Please click here
To view all translated materals including this page, select Japan from the country navigator on the bottom of this page.

ping

(To be removed) Retrieve status information about database connection

ping will be removed in a future release. Use these connection object properties instead:

  • MaxDatabaseConnections

  • DatabaseProductName

  • DatabaseProductVersion

  • DriverName

  • DriverVersion

Syntax

ping(conn)

Description

example

ping(conn) retrieves the status of the database connection conn.

Examples

collapse all

Create an Oracle® connection using an ODBC driver. This code assumes that you are connecting a data source named dbname with user name username and password pwd.

conn = database(dbname,username,pwd);

Retrieve the status of the Oracle connection.

ping(conn)
ans = 

  struct with fields:

       DatabaseProductName: 'Oracle'
    DatabaseProductVersion: '12.01.0020'
            ODBCDriverName: 'SQORA32.DLL'
         ODBCDriverVersion: '11.02.0004'
    MaxDatabaseConnections: 0
           CurrentUserName: 'username'
               DatabaseURL: ''
    AutoCommitTransactions: 'on'

ping returns these fields:

  • Database name

  • Database version

  • JDBC driver name

  • JDBC driver version

  • Maximum number of database connections allowed

  • User name for the current connection

  • Database URL

The last field denotes if the current database connection permits automatic commit of transactions.

Close the database connection.

close(conn)

Create a Microsoft® SQL Server® connection using a JDBC driver. For example, the following code assumes that you are connecting a data source named dbname with user name username, password pwd, database server name sname, and port number 123456.

conn = database('dbname','username','pwd',...
                'Vendor','Microsoft SQL Server','Server','sname',...
                'AuthType','Server','PortNumber',123456);

Retrieve the status of the Microsoft SQL Server connection.

ping(conn)
ans = 

       DatabaseProductName: 'Microsoft SQL Server'
    DatabaseProductVersion: '11.00.3000'
            JDBCDriverName: 'Microsoft JDBC Driver 4.0 for SQL Server'
         JDBCDriverVersion: '4.0.2206.100'
    MaxDatabaseConnections: 0
           CurrentUserName: 'username'
               DatabaseURL: 'jdbc:sqlserver:...'
    AutoCommitTransactions: 'True'

ping returns these fields:

  • Database name

  • Database version

  • JDBC driver name

  • JDBC driver version

  • Maximum number of database connections allowed

  • User name for the current connection

  • Database URL

The last field denotes if the current database connection permits automatic commit of transactions.

Close the database connection.

close(conn)

Input Arguments

collapse all

Database connection, specified as a connection object created using the database function.

Tips

  • When you use a connection object that is already closed in the ping function, the function returns the following error: Invalid connection. Create another connection to your database and try the ping function again.

Introduced before R2006a

Was this topic helpful?