I'm rather new to use go and am having issues connecting to an external mysql database. I'm using the go-sql-driver which seams rather nice. Suggestions to other drivers are welcomed!
this is the whole program:
import (
"database/sql"
_ "github.com/go-sql-driver/mysql"
"fmt"
)
const (
DB_HOST = "tcp(http://thedburl.com)"
DB_NAME = "nameofdatabase"
DB_USER = "username"
DB_PW = "password"
)
func main() {
dsn := DB_USER + ":" + DB_PW + "@" + DB_HOST + "/" + DB_NAME + "?charset=uf8"
db, err := sql.Open("mysql", dsn)
if err != nil {
fmt.Println("shiiet didn't work yo! Initialization failed")
}
defer db.Close() // go's purty cool
var str string
q := "SELECT * FROM forums"
err = db.QueryRow(q).Scan(&str)
if err != nil {
fmt.Println(err)
}
fmt.Println(str)
}
On the request I'm recieving the following error
"GetAddrInfoW: The specified class was not found."
Any ideas? I've siting for hours on the webs, and can't seem to solve the problem. It might be worth noting that I have used the same database service many times in java.