admissionServer/databaseConnection.go

31 lines
642 B
Go

package main
import (
"database/sql"
"fmt"
"log"
_ "github.com/denisenkom/go-mssqldb"
)
var connectionString = "server=192.168.1.3;Port=62262;database=DB_s439397;trusted_connection=yes;encrypt=disable"
//var connectionString = "server=MARCEL\\SQLEXPRESS;user id=;password="
var db *sql.DB
var err error
func testConnection() {
db, err = sql.Open("sqlserver", connectionString)
if err != nil {
log.Fatal("Error creating connection pool: ", err.Error())
}
//ctx := context.Background()
err = db.Ping()
//err = db.PingContext(ctx)
if err != nil {
log.Fatal(err.Error())
}
fmt.Printf("Connected!\n")
fmt.Println("..I..")
}