rana / ora

An Oracle database driver in Go.
MIT License
271 stars 65 forks source link

Stmt.exeC Env.ociError ORA-03135: connection lost contact\nProcess ID: 61366\nSession ID: 2867 Serial number: 6006 #262

Open chakrapani123 opened 5 years ago

chakrapani123 commented 5 years ago

hello,

i am making updates to oracle version 12.2.0.1 & ORA.V4 and using the following code snippet..

func (o *Oracle) UnReserveCdb(cdbname string) (unreserved bool, err error) {

fmt.Println(cdbname) udb := o.Db utx, err := udb.Begin() if err != nil { fmt.Println("error", err) } ures, err := utx.Exec("update testdb.DATABASE_INFO set CDB_CONSUMED = 'YES' , CDB_AVAILABLE = 'NO' where CDB_NAME = :1", cdbname) if err != nil { fmt.Println("error in exec: ", err) utx.Rollback() return unreserved, err } if err := utx.Commit(); err != nil { fmt.Println("error", err) } urowCnt, err := ures.RowsAffected() if err != nil { fmt.Println("error", err) } fmt.Println("rows changed ", urowCnt)

if urowCnt > 0 { return true, err } else { return false, err } }

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

func NewOracleConnection(cfg config.Config, log log.Logger) (Connection, error) { var err error o := &Oracle{ Driver: cfg.DB.Driver, ConnectString: cfg.DB.ConnectString, logger: log, } o.Db, err = sql.Open(o.Driver, o.ConnectString) if err != nil { log.Log("event", "connecting to database", "err", err.Error()) } return o, err }

thanks Chakri

tgulacsi commented 5 years ago

Just use gopkg.in/goracle.v2, that's maintained!

BTW, you haven't stated what's your problem with the given code...

chakrapani123 commented 5 years ago

sorry..might have jumped the gun on this one..when i do an update and commit post update

ures, err := utx.Exec("update testdb.DATABASE_INFO set CDB_CONSUMED = 'YES' , CDB_AVAILABLE = 'NO' where CDB_NAME = :1", cdbname) if err != nil { fmt.Println("error in exec: ", err) utx.Rollback() return unreserved, err } if err := utx.Commit(); err != nil { fmt.Println("error", err) }

i get this error

Stmt.exeC Env.ociError ORA-03135: connection lost

select statements work fine its just updates throw this error

thanks CHakri

tgulacsi commented 5 years ago

Sorry, no idea - this should work.

Can you try gopkg.in/goracle.v2 ? Just blank import it (import _ "gopkg.in/goracle.v2") instead of gopkg.in/rana/ora.v4 and use

db, err := sql.Open("goracle", "...")
...

and when you run your test, set the "DPI_DEBUG_LEVEL" environment variable to something bigger than 0. This will print a lot of debug information. Then the ODPI-C folks may be able to help.