简体   繁体   中英

How to connect to TimesTen database using golang?

I am trying to connect TimesTen database using golang, but no TimesTen driver for golang is available I can find.

Does anybody have such experience using golang to access TimesTen?

Since TimesTen supports OCI api. So I am trying to use a go package called goracle at https://github.com/go-goracle/goracle but failed.

Here is my sys.odbc.ini and sys.tt for TimesTen:

[root@centos-7 ~]# more /var/TimesTen/sys.odbc.ini

[ODBC Data Sources] TT_1122=TimesTen 11.2.2 Driver sampledb_1122=TimesTen 11.2.2 Driver sampledbCS_1122=TimesTen 11.2.2 Client Driver

[TT_1122] Driver=/opt/TimesTen/tt1122/lib/libtten.so DataStore=/var/TimesTen/tt1122/TT_1122 DatabaseCharacterSet=US7ASCII

[sampledb_1122] Driver=/opt/TimesTen/tt1122/lib/libtten.so DataStore=/var/TimesTen/tt1122/DemoDataStore/sampledb_1122 PermSize=40 TempSize=32 PLSQL=1 DatabaseCharacterSet=US7ASCII

[sampledbCS_1122] TTC_SERVER=ttLocalHost_tt1122 TTC_SERVER_DSN=sampledb_1122 Driver=/opt/TimesTen/tt1122/lib/libttclient.so

--

[root@centos-7 TimesTen]# more sys.ttconnect.ini

[ttLocalHost_tt1122] Description=TimesTen Server Network_Address=ttLocalHost TCP_PORT=53397

db, err := sql.Open("goracle","root/XXXXXXX@localhost:53397/sampledbCS_1122:timesten_client") // Trying to use this connect string for TimesTen, I am not sure if it is correct.

When running my test app, it reports error as below:

[root@centos-7 ttrest]#./ttrest Error running query username="root" SID="localhost:53397/sampledbCS_1122:timesten_client" minSessions=1 maxSessions=1000 poolIncrement=1 extAuth=0: ORA-29158: Unable to open library.

The best way to access Go from Oracle TimesTen In-memory Database is to use the ODPI-C based go-goracle SQL driver.

You should use tnsnames.ora to specify a TimesTen service name that will be used to connect to Go. The way you use go-goracle is the same whether you use TimesTen or the Oracle RDBMS.

You can run bin/ttenv.sh to set environment variable, but i can connect from window but i am not yet connect from linux

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM