on 2017 Jul 12 3:28 PM
I've been successfully using SQLAPI++ to connect and execute SQL statements against Oracle 11.2.0.4 and PostgreSQL 9.6.3. I've had no joy with SQL Anywhere 17 however.
The g++ command I use is:
$ export LD_LIBRARY_PATH=/opt/sqlanywhere17/lib64:$LD_LIBRARY_PATH
$ g++ -g -Wall -std=c++14 -o sa_connect_test sa_connect_test.o /home/bluefrog/SQLAPI/lib/libsqlapi.a -L/usr/lib/x86_64-linux-gnu -lpthread -pthread -lboost_thread -DBOOST_THREAD_VERSION=4 -lboost_system -ldl -lpq
There are no compile or link errors. Connection to PostgreSQL and execution of statements are successful
$ ~/bin/pgstart.sh
$ ./pg_connect_test
Row : x = 1, y = 'Fill'
Row : x = 2, y = 'Pop'
$ ~/bin/pgstop.sh
The same code, apart from the connect string returns the same result on Oracle (the same table name and data exists on all 3 databases).
Connection to SQL Anywhere however returns the following runtime error:
$ ~/bin/sastart.sh
$ ./sa_connect_test
libdbcapi.so: cannot open shared object file: No such file or directory
DBMS API Library loading fails
This library is a part of DBMS client installation, not SQLAPI++
Make sure DBMS client is installed and
this required library is available for dynamic loading
$ ~/bin/sastop.sh
Bu the file does exist:
$ ls -l /opt/sqlanywhere17/lib64/libdbcapi.so
lrwxrwxrwx 1 bluefrog bluefrog 14 Jul 12 11:48 /opt/sqlanywhere17/lib64/libdbcapi.so -> libdbcapi.so.1
and the LD_LIBRARY_PATH is set correctly
$ echo $LD_LIBRARY_PATH
/opt/sqlanywhere17/lib64:/home/bluefrog/SQLAPI/lib
The test code looks as follows:
include \\<stdio.h>
include </home>
int main(int argc, char* argv[]) {
SAConnection con;
SACommand cmd(&con, "select x, y from test1");
try {
//con.Connect("localhost,5432@ft_node", "bluefrog", "bluefrog", SA_PostgreSQL_Client);
//con.Connect("//localhost:1521/ftnode", "ordb", "ordb", SA_Oracle_Client);
con.Connect("localhost,2638@ftnode_sa", "sadb", "sadb", SA_SQLAnywhere_Client);
cmd.Execute();
while(cmd.FetchNext())
printf("Row : x = %ld, y = '%s'\\n", cmd.Field("x").asLong(), (const char*)cmd.Field("y").asString());
}
catch(SAException &x) {
try {
con.Rollback();
}
catch(SAException &) { }
printf("%s\\n", (const char*)x.ErrText());
}
return 0;
};
I do not understand why the library file is not been found. Any suggestion ?
User | Count |
---|---|
81 | |
11 | |
10 | |
10 | |
10 | |
8 | |
7 | |
7 | |
5 | |
5 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.