SMA and LLA Guide : Creating and running LLA applications : Starting and shutting down LLA server : Implicit startup with ODBC API function call SQLConnect
  
Implicit startup with ODBC API function call SQLConnect
When function SQLConnect is called for the first time, the server is implicitly started. The server is shut down implicitly when the user application calls function SQLDisconnect, which is the last open local connection.
Notes
The server shuts down regardless of currently existing remote connections.
When you start the server for the first time, you must create a solidDB® database by using function SSCStartServer() and specifying the default database catalog, along with the administrator username and password. For a description and example, read Explicit startup with SSC API function SSCStartServer.
Example
This is an example of implicit startup and shutdown with SQLConnect and SQLDisconnect:
/* Connection #1 */
rc = SQLConnect (hdbc1, "", SQL_NTS, "dba", SQL_NTS, "dba",
SQL_NTS); //Server Started Here
... odbc calls
/* Disconnect #1 */
SQLDisconnect (hdbc1); //Server Shut Down Here
/* Connection #2 */
rc = SQLConnect (hdbc2, "", SQL_NTS, "dba", SQL_NTS, "dba",
SQL_NTS); //Server Started Here
... odbc calls
/* Disconnect #2 * /
SQLDisconnect (hdbc2); //Server Shut Down Here
or
/* Connection #1*/
rc = SQLConnect (hdbc1, "", SQL_NTS, "dba",
SQL_NTS, "dba", SQL_NTS); // Server Started Here
/* Connection #2*/
rc = SQLConnect (hdbc2, "", SQL_NTS, "dba", SQL_NTS, "dba", SQL_NTS);
... odbc calls
/* Disconnect #1 */
SQLDisconnect (hdbc1);
/* Disconnect #2 * /
SQLDisconnect (hdbc2); // Server Shut Down Here
Note If the server is started with the SSCStartServer function call, the SQLDisconnect function call does not do implicit shutdown. The server must be shut down explicitly, either by SSCStopServer function call, the ADMIN COMMAND 'shutdown' command, or other explicit shutdown methods.
SscStateT runflags = SSC_STATE_OPEN;
SscServerT server;
SQLHDBC hdbc;
SQLHENV henv;
SQLHSTMT hstmt;
/* Start the server */
SSCStartServer (argc, argv, &server, runflags);
// Server Started Here
/* Alloc environment */
rc = SQLAllocEnv (&henv);
/* Connect to the database */
rc = SQLAllocConnect (henv, &hdbc);
rc = SQLConnect (hdbc, "", SQL_NTS, "dba", SQL_NTS, "dba", SQL_NTS);
/* Delete all the rows from table foo */
rc = SQLAllocStmt (hdbc, &hstmt):
rc = SQLExecDirect (hsmt, (SQLCHAR *) "DELETE FROM FOO", SQL_NTS);
/* Commit */
rc = SQLTransact (henv, hdbc, SQL_COMMIT);
rc = SQLFreeStmt (hstmt, SQL_DROP);
/* Disconnect */ SQLDisconnect (hdbc); SQLFreeConnect (hdbc);
/* Free the environment */
SQLFreeEnv(henv);
/* Stop the server */
SSCStopServer (server, TRUE); // Server Shut Down Here
See also
Starting and shutting down LLA server