Click here to view and discuss this page in DocCommentXchange. In the future, you will be sent there automatically.

SQL Anywhere 11.0.0 » SQL Anywhere Server - Database Administration » Starting and Connecting to Your Database » Connecting to a database

 

Connection parameter tips

Connection parameters often provide more than one way of accomplishing a given task. This is particularly the case with embedded databases, where the connection string starts a database server. For example, if your connection string starts a database, you can specify the database name using the DatabaseName (DBN) connection parameter or using the DatabaseSwitches (DBS) parameter. The Database Name (DBN) connection parameter is recommended.

Here are some recommendations and notes for situations where connection parameters conflict:

  • Specify database files using DBF   You can specify a database file in the StartLine (START) parameter or using the DatabaseFile (DBF) connection parameter (recommended).

  • Specify database names using DBN   You can specify a database name in the StartLine (START) parameter, the DatabaseSwitches (DBS) connection parameter, or using the DatabaseName (DBN) connection parameter (recommended).

  • Specify database server names using ENG   You can specify the name of the database server in the ServerName (ENG) parameter when you are attempting to autostart a database file if it is not already running. This ensures that the database connects to the intended database server.

  • Use the Start parameter to specify cache size   Even though you use the DatabaseFile (DBF) connection parameter to specify a database file, you may still want to tune the way in which it starts. You can use the StartLine (START) connection parameter to do this.

    For example, suppose you want to provide additional cache memory in the StartLine (START) connection parameter. The following set of embedded database connection parameters starts a database server with extra cache:

    DBF=samples-dir\demo.db
    DBN=Sample
    ENG=Sample Server
    UID=DBA
    PWD=sql
    START=dbeng11 -c 8M

Notes about connection parameters
  • Connection strings containing spaces   You must enclose the entire connection string in double quotes if any of the connection parameter values contain spaces.

  • Boolean values   Boolean (true or false) arguments are either YES, ON, 1, TRUE, Y, or T if true, or NO, OFF, 0, FALSE, N, or F if false.

  • Case sensitivity   Connection parameters are case insensitive, although their values may not be (for example, file names on Unix).

    The connection parameters used by the interface library can be obtained from the following places (in order of precedence):

    • Connection string   You can pass parameters explicitly in the connection string.

    • SQLCONNECT environment variable   The SQLCONNECT environment variable can store connection parameters.

    • Data sources   ODBC data sources can store parameters.

  • Character set restrictions   It is recommended that the server name must be composed of the ASCII character set in the range 1 to 127. There is no such limitation on other parameters.

  • Priority   The following rules govern the priority of parameters:

    • The entries in a connect string are read left to right. If the same parameter is specified more than once, the last one in the string applies. ODBC, OLE DB, Sybase Central, Interactive SQL, and the SQL Anywhere Console utility are exceptions to this: if the same parameter is specified more than once, the first string applies.
    • If a string contains a data source or file data source entry, the profile is read from the configuration file, and the entries from the file are used if they are not already set. For example, if a connection string contains a data source name and sets some of the parameters contained in the data source explicitly, then in case of conflict the explicit parameters are used.

  • Connection string parsing   If there is a problem parsing the connection string, an error is generated that indicates which connection parameter caused the problem.

  • Empty connection parameters   Connection parameters that are specified with empty values are treated as a zero length string.

See also