go-oci8 ORA-12545: Connect failed because target host or object does not exist

234 views
Skip to first unread message

cakn...@gmail.com

unread,
Aug 4, 2015, 8:36:55 AM8/4/15
to golang-nuts

I'm trying to use go-oci8 on my project. I use OSX. I already prepare the oracle instantclient and everything, and I can finally use it using sqlplus.


This is my tnsnames.ora

210=(DESCRIPTION=
        (ADDRESS_LIST=
            (ADDRESS=
                (PROTOCOL=TCP)
                (HOST=192.168.0.210)
                (PORT=1521)
            )
        )
        (CONNECT_DATA=
            (SID=ORCL)
            (SERVER=DEDICATED)
            (SERVICE_NAME=orcl.my.local)
        )
    )


This is the env.

export ORACLE_HOME=/Applications/oracle/instantclient_11_2
export PKG_CONFIG_PATH=$ORACLE_HOME/pkg
export GO_OCI8_CONNECT_STRING="(DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=TCP)(HOST=192.168.0.210)(PORT=1521)))(CONNECT_DATA=(SID=ORCL)(SERVER=DEDICATED)(SERVICE_NAME=orcl.my.local)))"
export ORACLE_SID="ORCL"
export DYLD_LIBRARY_PATH=$ORACLE_HOME:$DYLD_LIBRARY_PATH
export PATH=$PATH:$ORACLE_HOME

It's working if I use sqlplussqlplus scott/tiger@210.


---


Connect using sqlplus




The problem is I cannot connect to the oracle server using go-oci8 example.

I have put oci8.pc file inside $PKG_CONFIG_PATH and below is the content of the file.

orainc=/Applications/oracle/instantclient_11_2/sdk/include
oralib=/Applications/oracle/instantclient_11_2

Name: oci8
Description: Oracle Instant Client
Version: 12.1
Cflags: -I${orainc}
Libs: -L${oralib} -lclntsh


Everytime I run it, this error always showing up.


ORA-12545: Connect failed because target host or object does not exist

Can't connect to oracle server from golang


Could you help me solving this problem? Or am I missing something. Thank you in advance.

Didier Spezia

unread,
Aug 4, 2015, 10:45:37 AM8/4/15
to golang-nuts, cakn...@gmail.com

Looking at the source code (oracle.go):


fmt.Fprintln(os.Stderr, `Please specifiy connection parameter in GO_OCI8_CONNECT_STRING environment variable,
or as the first argument! (The format is user/name@host:port/sid)`)

So it seems the format you use for  GO_OCI8_CONNECT_STRING is wrong.

Regards,
Didier.
Reply all
Reply to author
Forward
0 new messages