denisenkom / go-mssqldb

Microsoft SQL server driver written in go language
BSD 3-Clause "New" or "Revised" License
1.82k stars 500 forks source link

run error #65

Closed zhurizeng closed 7 years ago

zhurizeng commented 9 years ago
db, err := sql.Open("mssql", "server=127.0.0.1;port=1433;user id=web;password=web;port=1433;database=eral")
if err != nil {
    fmt.Println("1", err)
    //  panic(err)
}
err = db.Ping()
if err != nil {
    fmt.Println("Cannot connect: ", err.Error())
    return
}

run this line :

err = db.Ping()

error:

panic: EOF goroutine 1 [running]: github.com/denisenkom/go-mssqldb.(_tdsBuffer).BeginRead(0x120a8b60, 0x4000000) d:/mygo/src/github.com/denisenkom/go-mssqldb/buf.go:112 +0xb0 github.com/denisenkom/go-mssqldb.readPrelogin(0x120a8b60, 0x0, 0x0, 0x0) d:/mygo/src/github.com/denisenkom/go-mssqldb/tds.go:175 +0x58 github.com/denisenkom/go-mssqldb.connect(0x120a89c0, 0x0, 0x0, 0x0) d:/mygo/src/github.com/denisenkom/go-mssqldb/tds.go:609 +0xce7 github.com/denisenkom/go-mssqldb.(_MssqlDriver).Open(0x718414, 0x59a588, 0x61, 0x0, 0x0, 0x0, 0x0) d:/mygo/src/github.com/denisenkom/go-mssqldb/mssql.go:110 +0x5c database/sql.(_DB).conn(0x1206c140, 0x561988, 0x0, 0x0) c:/go/src/database/sql/sql.go:659 +0x414 database/sql.(_DB).Ping(0x1206c140, 0x0, 0x0) c:/go/src/database/sql/sql.go:457 +0x38 main.main() D:/mygo/beedb/msdb.go:17 +0x15c goroutine 5 [chan receive]: database/sql.(*DB).connectionOpener(0x1206c140) c:/go/src/database/sql/sql.go:584 +0x43 created by database/sql.Open

c:/go/src/database/sql/sql.go:447 +0x256

how to fix?

dimdin commented 9 years ago

What version of SQL server do you use? If you use 2008 or 2008 R2 is it patched? See Known issues in README https://github.com/denisenkom/go-mssqldb/blob/master/README.md#known-issues

zhurizeng commented 9 years ago

I use SQL server version is mssql2005(os win8.1 or winxp). Sometime can bee run finish.

sometime return err : 1---------------------------------------------------------------------------------------- panic: EOF [recovered] panic: EOF

goroutine 7 [running]: github.com/denisenkom/go-mssqldb.func¡¤001() d:/mygo/src/github.com/denisenkom/go-mssqldb/token.go:403 +0x1b7 github.com/denisenkom/go-mssqldb.(*tdsBuffer).BeginRead(0x11fa3920, 0x0) d:/mygo/src/github.com/denisenkom/go-mssqldb/buf.go:112 +0xb0 github.com/denisenkom/go-mssqldb.processResponse(0x11fa82c0, 0x11fa8340, 0x0, 0x0) d:/mygo/src/github.com/denisenkom/go-mssqldb/token.go:412 +0xb5 created by github.com/denisenkom/go-mssqldb.connect d:/mygo/src/github.com/denisenkom/go-mssqldb/tds.go:629 +0xe19

goroutine 1 [chan receive]: github.com/denisenkom/go-mssqldb.connect(0x11fa36c0, 0x0, 0x0, 0x0) d:/mygo/src/github.com/denisenkom/go-mssqldb/tds.go:631 +0xe69 github.com/denisenkom/go-mssqldb.(_MssqlDriver).Open(0x611ff4, 0x5838c8, 0x54, 0x0, 0x0, 0x0, 0x0) d:/mygo/src/github.com/denisenkom/go-mssqldb/mssql.go:110 +0x5c database/sql.(_DB).conn(0x11fac1e0, 0x11fdfef4, 0x0, 0x0) c:/go/src/database/sql/sql.go:659 +0x414 database/sql.(_DB).query(0x11fac1e0, 0x580268, 0x37, 0x0, 0x0, 0x0, 0x40ed64, 0x0, 0x0) c:/go/src/database/sql/sql.go:928 +0x38 database/sql.(_DB).Query(0x11fac1e0, 0x580268, 0x37, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0) c:/go/src/database/sql/sql.go:919 +0x83 main.main() E:/1.go:16 +0x179

goroutine 5 [chan receive]: database/sql.(*DB).connectionOpener(0x11fac1e0) c:/go/src/database/sql/sql.go:584 +0x43 created by database/sql.Open c:/go/src/database/sql/sql.go:447 +0x256 2-------------------------------------------------------------------------------------- panic: EOF

goroutine 1 [running]: github.com/denisenkom/go-mssqldb.(_tdsBuffer).BeginRead(0x11f43920, 0x4000000) d:/mygo/src/github.com/denisenkom/go-mssqldb/buf.go:112 +0xb0 github.com/denisenkom/go-mssqldb.readPrelogin(0x11f43920, 0x0, 0x0, 0x0) d:/mygo/src/github.com/denisenkom/go-mssqldb/tds.go:175 +0x58 github.com/denisenkom/go-mssqldb.connect(0x11f436c0, 0x0, 0x0, 0x0) d:/mygo/src/github.com/denisenkom/go-mssqldb/tds.go:609 +0xce7 github.com/denisenkom/go-mssqldb.(_MssqlDriver).Open(0x611ff4, 0x5838c8, 0x54, 0x0, 0x0, 0x0, 0x0) d:/mygo/src/github.com/denisenkom/go-mssqldb/mssql.go:110 +0x5c database/sql.(_DB).conn(0x11f4c1e0, 0x11f7fef4, 0x0, 0x0) c:/go/src/database/sql/sql.go:659 +0x414 database/sql.(_DB).query(0x11f4c1e0, 0x580268, 0x37, 0x0, 0x0, 0x0, 0x40ed64, 0x0, 0x0) c:/go/src/database/sql/sql.go:928 +0x38 database/sql.(*DB).Query(0x11f4c1e0, 0x580268, 0x37, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0) c:/go/src/database/sql/sql.go:919 +0x83 main.main() E:/1.go:16 +0x179

goroutine 5 [runnable]: database/sql.(*DB).connectionOpener(0x11f4c1e0) c:/go/src/database/sql/sql.go:584 +0x43 created by database/sql.Open

c:/go/src/database/sql/sql.go:447 +0x256

err code line 16 is: rows,err:=db.Query("selectid,ipfromtest_recordwhereid>1700andid<2000")

Thank!

At 2014-11-14 01:45:54,"Dimitris Dinodimos" notifications@github.com wrote:

What version of SQL server do you use? If you use 2008 or 2008 R2 is it patched? See Known issues in README https://github.com/denisenkom/go-mssqldb/blob/master/README.md#known-issues

¡ª Reply to this email directly or view it on GitHub.

dimdin commented 9 years ago

It seems that you don't run the latest code. Can you update the code using: go get -u github.com/denisenkom/go-mssqldb