go-ora icon indicating copy to clipboard operation
go-ora copied to clipboard

Received code N error after using for a period of time

Open Niexiawei opened this issue 11 months ago • 0 comments

error

310343659-e7861afa-4ef1-4526-97a0-0af887096bc0

code

//connection
options := map[string]string{
		"TIMEOUT":  "300",
	}
	if val := viper.GetString("database.oracle.sid"); val != "" {
		options["SID"] = val
	}
	dsn := go_ora.BuildUrl(viper.GetString("database.oracle.host"),
		viper.GetInt("database.oracle.port"),
		viper.GetString("database.oracle.service"),
		viper.GetString("database.oracle.user"),
		viper.GetString("database.oracle.pwd"), options)

	conn, err := sql.Open("oracle", dsn)
	conn.SetMaxIdleConns(50)
	conn.SetMaxOpenConns(50)
	if err != nil {
		panic(err)
		return
	}
	OracleConn = conn


//Query

rows, err := OracleConn.Query("select * from GCJL where GCSJ >= to_date(:1,'yyyy-mm-dd hh24:mi:ss') and GCSJ <= to_date(:2,'yyyy-mm-dd hh24:mi:ss')", "2024-03-05 00:00:00","2024-03-05 02:00:00")
	if err != nil {
		return nil, err
	}
	defer rows.Close()
	columns, err := rows.Columns()
	if err != nil {
		return nil, err
	}
	for rows.Next() {
		res := make([]any, len(columns))
		_ = rows.Scan(res...)
	}

Niexiawei avatar Mar 06 '24 02:03 Niexiawei