How To Change My Db Connection String In Sitecontroller?

I Create Config/Main.php a default database connection string…, can i modify or edit dynamically before login time in sitecontroller … please help me!

Perhaps is possible by changing CDbConnection::connectionString, I’m not sure about it.

$conn = new CDbConnection(DSN, username, password);

$conn->active = true;