dbInfo := DbInfo{ Username: "ADMIN", Password: "Ddbstjrld1!a", Server: "adb.ap-seoul-1.oraclecloud.com", Port: "1522", Service: "gee9edfb92f3cf6_redglqwayxqefhhf_high.adb.oraclecloud.com", WalletLocation: "/Users/temp1/Desktop/Wallet_REDGLZWEYXQEFHHF", }
dbString := fmt.Sprintf(`user="%v" password="%v" connectString="tcps://%s:%s/%s?wallet_location=%s"`, dbInfo.Username, dbInfo.Password, dbInfo.Server, dbInfo.Port, dbInfo.Service, dbInfo.WalletLocation)
db, err := sql.Open("godror", dbString)
if err != nil {
fmt.Println(err.Error())
}
defer db.Close()
r, err := db.Exec(`CREATE TABLE member_table (
seq INT NOT NULL AUTO_INCREMENT,
mb_id VARCHAR(20),
mb_pw VARCHAR(100),
address VARCHAR(100),
mb_tell VARCHAR(20),
PRIMARY KEY(seq)
) ENGINE= MYISAM CHARSET=utf8;`)
if err != nil {
fmt.Println(err.Error())
}
fmt.Println(r)
I am using oracle for the first time. I checked the manual and followed it, but I can't solve it.
Error running query
ORA-00000: DPI-1047: Cannot locate a 64-bit Oracle Client library: "dlopen(libclntsh.dylib, 0x0001): tried: 'libclntsh.dylib' (no such file), '/usr/local/lib/libclntsh.dylib' (no such file), '/usr/lib/libclntsh.dylib' (no such file), '/Users/temp1/project/oracleDatabase/libclntsh.dylib' (no such file)". See https://oracle.github.io/odpi/doc/installation.html#macos for help
temp@temp-MacBookPro oracleDatabase %
When connecting through dbeaver, it works normally, but when connecting with the above code in golang, the following error is returned.
I've been struggling for several days, if you show me a simple example, I think I can study while analyzing it, can you help me?
CodePudding user response:
As per the mentioned error, you need to import oracle driver goracle
for database/sql
to work with an oracle database.
import (
"database/sql"
// Import the Oracle driver
_ "gopkg.in/goracle.v2"
)
P.S.: I would suggest to add line number in question statement which raised that error so that it can be debugged easily.