39 lines
1.5 KiB
C#
39 lines
1.5 KiB
C#
using MySqlConnector;
|
|
|
|
namespace TWASys_App.DBModels
|
|
{
|
|
public class DBManagement
|
|
{
|
|
public static string GetConnectionString(bool allowVar = false)
|
|
{
|
|
string fp = Path.GetFullPath("Keys/db/");
|
|
|
|
var builder = new MySqlConnectionStringBuilder
|
|
{
|
|
Pooling = true, // mặc định đã true
|
|
MinimumPoolSize = 0, // số kết nối nền tối thiểu
|
|
MaximumPoolSize = 400, // tăng nếu tải đồng thời cao
|
|
ConnectionLifeTime = 2520,
|
|
ConnectionIdleTimeout = 1080, //
|
|
Keepalive=60,
|
|
InteractiveSession = true, // dùng interactive_timeout thay vì wait_timeout
|
|
ConnectionReset = true,
|
|
Server = "103.116.104.146",
|
|
Port = 3306,
|
|
Database = "Storage_TWA_DB",
|
|
UserID = "apptwa",
|
|
Password = "Twa@2025!StorageDB",
|
|
// TLS/SSL
|
|
SslMode = MySqlSslMode.Required, // hoặc VerifyCA / VerifyFull nếu có hostname chuẩn
|
|
SslCa = Path.Combine(fp, "ca-cert.pem"),
|
|
SslCert = Path.Combine(fp, "client-cert.pem"),
|
|
SslKey = Path.Combine(fp, "client-key.pem"),
|
|
AllowUserVariables = allowVar
|
|
};
|
|
//172.168.192.204
|
|
return builder.ConnectionString;
|
|
}
|
|
|
|
}
|
|
}
|