go-goracle / goracle

Go database/sql driver for connecting to Oracle Database, using the ODPI-C library
273 stars 43 forks source link

connection timeout issues #173

Closed chakrapani123 closed 5 years ago

chakrapani123 commented 5 years ago

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

tgulacsi commented 5 years ago

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