﻿package main
import (
	"context"
	"fmt"
	"github.com/jackc/pgx/v5/pgxpool"
)
func main() {
	dsns := []string{
		"postgresql://postgres:postgres123@localhost:5432/postgres?sslmode=disable",
		"postgresql://postgres:postgres@localhost:5432/postgres?sslmode=disable",
		"postgresql://postgres:admin@localhost:5432/postgres?sslmode=disable",
	}
	for _, dsn := range dsns {
		pool, err := pgxpool.New(context.Background(), dsn)
		if err != nil { fmt.Println("connect err:", err); continue }
		if err := pool.Ping(context.Background()); err != nil {
			pool.Close()
			fmt.Println("ping err:", err)
			continue
		}
		var v string
		pool.QueryRow(context.Background(), "SELECT version()").Scan(&v)
		fmt.Println("OK:", dsn[:50])
		fmt.Println("  ", v[:40])
		pool.Close()
		return
	}
}