Skip to content

netlib: unexpected EOF while reading message #32

@akash7301

Description

@akash7301

my password having special characters like "#" and "|", when I'm trying to connect using perl it connecting successfully but golang is giving error : netlib: unexpected EOF while reading message

here is my code snippet
can you please help what is wrong in this, do i need to encode password into something?
`import (
"database/sql"
_ "github.com/thda/tds"
)

func getConn(cred map[string]string) (c *sql.DB) {
Name := cred["NAME"]
Pass := cred["PASS"] // 6#A(co&k|31V
Server := cred["SERVER"]
User := cred["USER"]
Port := cred["PORT"]
// dbConn := fmt.Sprintf("dbname=%s host=%s port=%s user=%s password=%s", Name, Server, Port, User, Pass)
cnxStr := "tds://" + url.QueryEscape(User) + ":" + url.QueryEscape(Pass) + "@" + Server + ":" + Port + "/" + Name + "?charset=utf8"
conn, err := sql.Open("tds", cnxStr)
if err != nil {
fmt.Println("Open Connection failed..", err)
panic(err)
}
conn.SetConnMaxLifetime(time.Minute * 4)
conn.SetMaxIdleConns(0)
defer conn.Close()
if err := conn.Ping(); err != nil {
log.Println("sql.Ping failed:", err.Error())
return nil
}

return conn

}`

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions