Connecting to an embedded database

An embedded database, designed for use by a single application, runs on the same computer as the application and is largely hidden from the application's user.

When an application uses an embedded database, the personal server is generally not running when the application connects. In this case, you can start the database using the connection string, and by specifying the database file in the DatabaseFile (DBF) parameter of the connection string.

Using the DBF connection parameter

The DatabaseFile (DBF) connection parameter specifies which database file to use. The database file automatically loads onto the default server, or starts a server if none are running.

The database unloads when there are no more connections to the database (generally when the application that started the connection disconnects). If the connection started the server, the database server stops once the database unloads.

The following connection parameters show how to load the sample database as an embedded database:

DBF=samples-dir\demo.db
UID=DBA
PWD=sql

For information about samples-dir, see Samples directory.

Using the ENG connection parameter

It is recommended that you use the ServerName (ENG) connection parameter when using an embedded database. This ensures that the database will connect to the correct database server in case there are other applications running SQL Anywhere database servers on the same computer.

Using the StartLine [START] connection parameter

The following connection parameters show how you can customize the startup of the sample database as an embedded database. This is useful if you want to use options, such as the cache size:

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

There are a number of connection parameters that affect how a server is started. It is recommended that you use the following connection parameters instead of providing the corresponding server options within the StartLine (START) connection parameter:

Using the ELEVATE connection parameter

If you are autostarting a database server on Windows Vista, you must specify ELEVATE=YES in your connection string so that autostarted database server executables are elevated. On Windows Vista, only elevated database servers can use AWE memory or call procedures as an administrator user.

See also