Connection ConfigurationAny file that is in a DatabaseResources directory with an extension of .m will be inspected to see if it contains possible connection configuration information. Here is the format of a connection configuration file:
SQLConnection[ connectdata, "Name" -> "name", "Description" -> "text", "Username" -> "user", "Password" -> "pass", "RelativePath" -> True|False ]
where connectdata holds connection data (typically a JDBC setting), name is the name of the connection (as might be used in OpenSQLConnection), text is a textual description of the connection, and user and pass are the username and password to use when connecting to the database (a password of $Prompt causes a GUI to appear to enter the password). If the connection data involves a relative path, this is specified with the RelativePath setting. The version of the configuration file is specified by the Version setting. Here is an example file (configured for HSQLDB):
SQLConnection[ JDBC["hsqldb", "../Examples/example"], "Name" -> "example", "Description" -> "Connection to hsql db for documention.", "Username" -> "sa", "Password" -> "", "RelativePath" -> True, "Version" -> 1]
This file specifies that HSQLDB should be used to connect to the file Examples/example, which is found relative to the location of the configuration file. The username sa and a blank password are also given. This connection information is given the name example. This configuration file supports the following OpenSQLConnection command.
OpenSQLConnection["example"]
Here is another example file (configured for Oracle):
SQLConnection[ JDBC["oracle", "server.business.com:1999"], "Name" -> "businessDB", "Description" -> "Connection to Oracle db.", "Username" -> "server1", "Version" -> 1]
This specifies connection information to use when OpenSQLConnection is invoked with businessDB, such as the following command.
OpenSQLConnection["businessDB"]
Note that if you added an application to hold JDBC driver classes, as shown in a previous section, and JDBC configuration information as shown previously, you could use the same location for holding the Oracle connection information. The following table shows the layout of an application that could be used for connecting to Oracle.
If you did not wish to write the connection configuration file yourself, you could use the New Connection Wizard, described in a later section. When you have made a new named connection, you might want to go to the Named Connections section to confirm that the new connection is accessible to the system.
|