go-goracle / goracle

Go database/sql driver for connecting to Oracle Database, using the ODPI-C library

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

connection timeout issues

chakrapani123 opened this issue · comments

hello,

i ran into this bug with this driver and database/sql . i leverage this driver to do sql.open

//oracle is type oracle struct
type Oracle struct {
Driver string
ConnectString string
Db *sql.DB
// logger log.Logger
}

o := &Oracle{
	Driver:        "goracle",
	ConnectString: cString,
}

m.Db, err = sql.Open(m.Driver, m.ConnectString)

if err != nil {
fmt.Println("error in db", err)
return nil, err
}
mdb := m.Db
mdb.SetConnMaxLifetime(time.Minute)

use-case:1 : correct connect string without any typo issues works fine

however use-case2: wrong port it waits till tnstimeout setting to error out . wondering if there is a way to make this fail faster than wait for it to timeout

also, is there a way to do reset connection for every new request?

thanks
Chakri

SetConnMaxLifetime sets the connection's maximum lifetime, not the connection timeout.
The connection is a TCP one, through ODPI-C, which calls OCI, which uses the client-side sqlnet.ora file - see https://www.php.net/manual/en/function.oci-connect.php#84144