Created with Raphaël 2.1.0
    Loading...
Skip to end of metadata
Go to start of metadata

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 16 Next »

ORACLE

EXEC SQL CONNECT { :user IDENTIFIED BY :oldpswd | :usr_psw }
  [{ AT [dbname | :host_variable }] USING :connect_string ]
    [ {ALTER AUTHORIZATION :newpswd | IN { SYSDBA | SYSOPER } MODE } ];

Sample Code

char *username = "SCOTT";
char *password = "TIGER";
...
EXEC SQL WHENEVER SQLERROR ...
EXEC SQL CONNECT :username IDENTIFIED BY :password;

ALTIBASE

EXEC SQL {AT :host_variable} CONNECT { :user IDENTIFIED BY :user_passwd} {USING :connect_string};

Sample Code

char *username = "SYS";
char *password = "MANAGER";
...
EXEC SQL WHENEVER SQLERROR ...
EXEC SQL CONNECT :username IDENTIFIED BY :password;
  • APRE doesn't support a syntax with "ALTER AUTHORIZATION".
  • APRE doesn't support a syntax with "IN {SYSDBA | SYSOPER} MODE".
  • APRE doesn't support a functionality for auto-connection.

Using AT

When you need to connect multiple database connections, use "AT" in your application source.

char usr[20];
char pwd[20];
char conn_name1[20];
char conn_name2[20];
...
sprintf (usr, "SYS");
sprintf (pwd, "MANAGER");
sprintf (conn_name1, "db_connection1");
sprintf (conn_name2, "db_connection2");
 
EXEC SQL AT :conn_name1 CONNECT :usr IDENTIFIED BY :pwd;
EXEC SQL AT :conn_name2 CONNECT :usr IDENTIFIED BY :pwd;
...
EXEC SQL AT :conn_name1 SELECT ...;
EXEC SQL AT :conn_name2 PREPARE ...;
  • ALTIBASE HDB doesn't provide context for multi-thread application. Therefore, User has to manage connections for multi-thread application.

Using connect_string

When you need to specifiy a target database, use "USING" in your application source.

char usr[20];
char pwd[20];
char conn_string[200];
...
sprintf (usr, "SYS");
sprintf (pwd, "MANAGER");
sprintf (conn_string, "DSN=192.168.1.35;PORT_NO=20300;NLS_USE=US7ASCII;CONN_TYPE=1");
EXEC SQL CONNECT :usr IDENTIFIED BY :pwd USING :conn_string;

Option

Meaning

DSN

To specify IP of database server.

PORT_NO

To specify PORT_NO of database server.

NLS_USE

To specify national character set of database server.

CONN_TYPE

To specify connection-type.

  • CONN_TYPE=1 : TCP/IP type
  • CONN_TYPE=2 : UNIX Domain Socket type
  • CONN_TYPE=3 : IPC type (use shared-memory area for communication buffer.)

TIMEOUT=n

To specify time-limitation of interval for trying to connect to DB-server.

CONNECTION_TIMEOUT=n

To specify time-limitation of interval for receiving a packet about result of SQL executed.

  • If you don't specify a connection_string, application try to connect a local-server.
  • TIMEOUT and CONNECTION_TIMEOUT is used to check immediately a network-error in your application ASAP.
  • You can set a user-environment variable to connect a database.
    export ALTIBASE_NLS_USE=US7ASCII
    export ALTIBASE_PORT_NO=20300

FailOver

AlTIBASE HDB provides functionality to fail-over, we called it as CTF and STF.
CTF is Connection-Time-Failover and STF is Serive-Time-Failover.
CTS is a functionality when application tries to connect a DBMS and gets a error for connection, application automatically tries to connect a other DBMS which user defined.
STF is a functiionality when application tries to execute a SQL and gets a connetion-error (as DBMS or Server was down) for connection, application automatically tries to connect a other DBMS which user defined.

Sample Code

EXEC SQL BEGIN DECLARE SECTION;
char usr[20];
char pwd[20];
char connt_opt[200];
EXEC SQL END DECLARE SECTION;
 
sprintf (usr, "SYS");
sprintf (pwd, "MANAGER");
sprintf (conn_opt, "DSN=192.168.3.54;PORT_NO=20300;CONNTYPE=1;AlternateServers=(192.168.3.54:20300,192.168.3.53:20300);ConnectionRetryCount=3;
 ConnectionRetryDelay=5;LoadBalance=on;SessionFailOver=on;"" );
 
EXEC SQL CONNECT :usr IDENTIFIED BY :pwd USING :conn_opt;
...
  • No labels