Document Type: Technical Information
Category: Interface/Integration
Document Number: TIITI016
Overview
The ESQL program connects to the database by referencing the TB_SID environment variable and the Tibero Client's tbdsn.tbr file.
If two or more connection details are specified in tbdsn.tbr, you can connect to the desired DB by changing the TB_SID environment variable.
Method
Registering Connection Information in tbdsn.tbr
The example below shows setting both local DB and remote DB connection information together.
#-------------------------------------------------
# /home/tibero/tibero5/client/config/tbdsn.tbr
# Network Configuration File.
# Generated by gen_tip.sh at Thu Dec 15 09:49:08 KST 2016
tibero=(
(INSTANCE=(HOST=localhost)
(PORT=8629)
(DB_NAME=tibero)
)
)
remote=(
(INSTANCE=(HOST=192.168.41.148)
(PORT=14330)
(DB_NAME=tac)
)
)
Testing with a Local DB Without a Connection User
centos1@tibero:/home/tibero # echo $TB_SID tibero centos1@tibero:/home/tibero # tbsql sys/tibero tbSQL 5 SP1 TmaxData Corporation Copyright (c) 2008-. All rights reserved. Connected to Tibero. SQL> drop user tibero; User 'TIBERO' dropped. SQL> q Disconnected. centos1@tibero:/home/tibero # ./test Connection Fail ( SQLCODE : -17001 ) !!
Testing with a Normal Remote DB
centos1@tibero:/home/tibero # TB_SID=remote
centos1@tibero:/home/tibero # echo $TB_SID
remote
centos1@tibero:/home/tibero # ./test
Connected to Tibero as user tibero
[result] col3 : [3
Setting the DB to Connect to by Only Changing TB_SID
centos1@tibero:/home/tibero # TB_SID=tibero
centos1@tibero:/home/tibero # ./test
Connection Fail ( SQLCODE : -17001 ) !!
centos1@tibero:/home/tibero # TB_SID=remote
centos1@tibero:/home/tibero # ./test
Connected to Tibero as user tibero
[result] col3 : [3As shown, even if there is an existing executable file, you can connect to the desired database simply by changing the TB_SID environment variable value.