Closed nvijayap closed 4 months ago
NOTE
: When using context
...
the code above use go-ora
v1?
Yes, the code above uses v1
. Here's the code (and run output) with v2
...
~/gora2 echo; cat gora2.go; echo; go run gora2.go; echo
package main
import (
"database/sql"
"fmt"
"os"
"strconv"
"strings"
"github.com/joho/godotenv"
"github.com/sijms/go-ora/v2"
)
type ConnSettings struct {
Host string
Port string
Service string
Username string
Password string
}
func main() {
godotenv.Load()
connSettings := ConnSettings{
strings.TrimSpace(os.Getenv("HO")),
strings.TrimSpace(os.Getenv("PO")),
strings.TrimSpace(os.Getenv("SN")),
strings.TrimSpace(os.Getenv("UN")),
strings.TrimSpace(os.Getenv("PW")),
}
err := ping(connSettings)
if err != nil {
fmt.Println(" main:", err)
return
}
fmt.Println("Connected successfully")
}
func ping(connSettings ConnSettings) error {
port, err := strconv.Atoi(connSettings.Port)
if err != nil {
return err
}
connStr := go_ora.BuildUrl(connSettings.Host, port, connSettings.Service,
connSettings.Username, connSettings.Password, nil)
conn, err := sql.Open("oracle", connStr)
if err != nil {
fmt.Println("sql.Open:", err)
return err
}
defer conn.Close()
err = conn.Ping()
if err != nil {
fmt.Println("conn.Ping:", err)
return err
}
return nil
}
conn.Ping: connection break due to context timeout
main: connection break due to context timeout
Something to do with Oracle Account Setup. After Locking and Unlocking the Account, and Expiry set to a year from now, the Connection/Ping is working reliably.
Something to do with Oracle Account Setup. After Locking and Unlocking the Account, and Expiry set to a year from now, the Connection/Ping is working reliably. NOTE
: Tested with the latest version of go-ora
-> v2.8.9
Hi,
I am consistently getting EOF with conn.Ping ; Code is below ...
Here's the script to run above code ...
And here's the output of run ...
Can you please look into this?
Thanks