Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

netlib: unexpected EOF while reading message #32

Open
akash7301 opened this issue Sep 13, 2023 · 0 comments
Open

netlib: unexpected EOF while reading message #32

akash7301 opened this issue Sep 13, 2023 · 0 comments

Comments

@akash7301
Copy link

akash7301 commented Sep 13, 2023

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

}`

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant