Answer the question
In order to leave comments, you need to log in
Why, when the connection pool is moved to the file level, does it panic?
This is how the database query works fine:
import (
_ "github.com/go-sql-driver/mysql"
)
func DBRout() {
// Пул подключений.
db, err_DB := sql.Open("mysql", ConnectDB)
if err_DB != nil {
fmt.Println("ERROR creating database connection pool:", err_DB)
}
defer db.Close()
db_ss.SetMaxOpenConns(25)
db_ss.SetMaxIdleConns(2)
db_ss.SetConnMaxLifetime(time.Minute)
// Запрос.
var err_DBQuery = db.QueryRow("SELECT COUNT(*) FROM `TabTab` WHERE `Col_User` = ? AND ColumnID = ?, 3, UName).Scan(&row_search)
if err_DBQuery != nil {
fmt.Println("Query error:", err_DBQuery)
return
}
}
func main() {
var mux = http.NewServeMux()
mux.HandleFunc("/routDB/", DBRout)
var serv = &http.Server {
...параметры...
}
log.Fatal(serv.ListenAndServeTLS(TLScert, TLSkey))
}
import (
_ "github.com/go-sql-driver/mysql"
)
var db *sql.DB
func DBRout() {
// Запрос.
var err_DBQuery = db.QueryRow("SELECT COUNT(*) FROM `TabTab` WHERE `Col_User` = ? AND ColumnID = ?, 3, UName).Scan(&row_search)
if err_DBQuery != nil {
fmt.Println("Query error:", err_DBQuery)
return
}
}
func main() {
// Пул подключений.
db, err_DB := sql.Open("mysql", ConnectDB)
if err_DB != nil {
fmt.Println("ERROR creating database connection pool:", err_DB)
}
defer db.Close()
db_ss.SetMaxOpenConns(25)
db_ss.SetMaxIdleConns(2)
db_ss.SetConnMaxLifetime(time.Minute)
var mux = http.NewServeMux()
mux.HandleFunc("/routDB/", DBRout)
var serv = &http.Server {
...параметры...
}
log.Fatal(serv.ListenAndServeTLS(TLScert, TLSkey))
}
Answer the question
In order to leave comments, you need to log in
Well, isn't it bullshit?? )
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question