SQLConnectionUsableQ[conn]
tests whether or not queries may be issued on conn.
SQLConnectionUsableQ[conn,{sql,res}]
expects result res when issuing sql on conn.
SQLConnectionUsableQ
SQLConnectionUsableQ[conn]
tests whether or not queries may be issued on conn.
SQLConnectionUsableQ[conn,{sql,res}]
expects result res when issuing sql on conn.
Details and Options
- To use SQLConnectionUsableQ, you first need to load DatabaseLink using Needs["DatabaseLink`"].
- SQLConnectionUsableQ is a server-side test and initiates communication with the connection's target server, local or remote.
Examples
open all close allBasic Examples (1)
Needs["DatabaseLink`"]If you find that the examples in this section do not work as shown, you may need to install or restore the example database with the "DatabaseLink`DatabaseExamples`" package, as described in Using the Example Databases.
Open a connection to a sample database:
conn = OpenSQLConnection["demo"]Test the connection's usability:
SQLConnectionUsableQ[conn]CloseSQLConnection[conn];Test the connection's usability again:
SQLConnectionUsableQ[conn]Generalizations & Extensions (1)
SQLConnectionUsableQ issues a test query whose contents depend on the RDBMS conn is connected to. When using custom drivers, use the two-argument form to supply your own test:
conn = OpenSQLConnection[JDBC["my.new.database.Driver", "jdbc:mnd:scratch"]]SQLConnectionUsableQ@conn;SQLConnectionUsableQ[conn, {"SELECT 1", {{1}}}]Properties & Relations (1)
Needs["DatabaseLink`"]SQLConnectionUsableQ initiates server communication and is therefore a stronger test than SQLConnectionOpenQ. However, it will generally take longer to evaluate:
conn = OpenSQLConnection["demo"];
AbsoluteTiming[#[conn]]& /@ {SQLConnectionOpenQ, SQLConnectionUsableQ}CloseSQLConnection[conn];