Index: /trunk/MagicSoft/Mars/msql/MSQLServer.cc
===================================================================
--- /trunk/MagicSoft/Mars/msql/MSQLServer.cc	(revision 4876)
+++ /trunk/MagicSoft/Mars/msql/MSQLServer.cc	(revision 4877)
@@ -46,4 +46,5 @@
 
 #include <TH1.h>
+#include <TEnv.h>
 
 #include <TSQLResult.h>
@@ -503,29 +504,6 @@
 }
 
-void MSQLServer::Init(const char *connection, const char *user, const char *password) /*FOLD00*/
-{
-    fType = kIsZombie;
-
-    fServ = TSQLServer::Connect(connection, user, password);
-    if (fServ)
-    {
-        gROOT->GetListOfBrowsables()->Add(this, connection);
-        fType = kIsServer;
-    }
-    else
-        SetBit(kZombie);
-
-    fList.SetOwner();
-}
-
-MSQLServer::MSQLServer(const char *connection, const char *user, const char *password) /*FOLD00*/
-{
-    Init(connection, user, password);
-}
-
-MSQLServer::MSQLServer(const char *u) : fType(kIsZombie) /*FOLD00*/
-{
-    TString url(u);
-
+Bool_t MSQLServer::Split(TString &url, TString &user, TString &pasw) const
+{
     const Ssiz_t pos1 = url.First("://")+3;
     const Ssiz_t pos2 = url.Last(':')   +1;
@@ -533,15 +511,88 @@
 
     if (pos1<0 || pos2<0 || pos3<0 || pos1>pos2 || pos2>pos3)
-    {
+        return kFALSE;
+
+    user = url(pos1, pos2-pos1-1);
+    pasw = url(pos2, pos3-pos2);
+
+    url.Remove(pos1, pos3+1-pos1);
+
+    return kTRUE;
+}
+
+void MSQLServer::Init(const char *connection, const char *user, const char *password) /*FOLD00*/
+{
+    fType = kIsZombie;
+
+    fServ = TSQLServer::Connect(connection, user, password);
+    if (fServ)
+    {
+        gROOT->GetListOfBrowsables()->Add(this, connection);
+        fType = kIsServer;
+    }
+    else
         SetBit(kZombie);
+
+    fList.SetOwner();
+}
+
+void MSQLServer::InitEnv(TEnv &env, const char *prefix)
+{
+    TString url; 
+    TString user;
+    TString pass;
+
+    if (prefix)
+    {
+        url  = env.GetValue(Form("%s.URL", prefix),      "");
+        user = env.GetValue(Form("%s.User", prefix),     "");
+        pass = env.GetValue(Form("%s.Password", prefix), "");
+    }
+    if (url.IsNull())
+        url  = env.GetValue("URL",      "");
+    if (user.IsNull())
+        user = env.GetValue("User",     "");
+    if (pass.IsNull())
+        pass = env.GetValue("Password", "");
+
+    if (user.IsNull() && pass.IsNull())
+    {
+        if (!Split(url, user, pass))
+        {
+            SetBit(kIsZombie);
+            return;
+        }
+    }
+
+    Init(url, user, pass);
+}
+
+MSQLServer::MSQLServer(const char *connection, const char *user, const char *password) /*FOLD00*/
+{
+    Init(connection, user, password);
+}
+
+MSQLServer::MSQLServer(const char *u) : fType(kIsZombie) /*FOLD00*/
+{
+    TString url(u);
+    TString user, pasw;
+
+    if (!Split(url, user, pasw))
+    {
+        SetBit(kIsZombie);
         return;
     }
-
-    const TString user = url(pos1, pos2-pos1-1);
-    const TString pasw = url(pos2, pos3-pos2);
-
-    url.Remove(pos1, pos3+1-pos1);
-
     Init(url, user, pasw);
+}
+
+MSQLServer::MSQLServer(TEnv &env, const char *prefix)
+{
+    InitEnv(env, prefix);
+}
+
+MSQLServer::MSQLServer()
+{
+    if (gEnv)
+        InitEnv(*gEnv);
 }
 
Index: /trunk/MagicSoft/Mars/msql/MSQLServer.h
===================================================================
--- /trunk/MagicSoft/Mars/msql/MSQLServer.h	(revision 4876)
+++ /trunk/MagicSoft/Mars/msql/MSQLServer.h	(revision 4877)
@@ -6,5 +6,7 @@
 #endif
 
+class TEnv;
 class TArrayI;
+
 class TSQLServer;
 class TSQLResult;
@@ -55,5 +57,8 @@
     const char *GetNameColumn()   const { return Form("%s/%s/%s", (const char*)fDataBase, (const char*)fTable, (const char*)fColumn); }
 
+    Bool_t Split(TString &url, TString &user, TString &pasw) const;
+
     void Init(const char *connection, const char *user, const char *password);
+    void InitEnv(TEnv &env, const char *prefix=0);
 
 public:
@@ -80,4 +85,6 @@
     MSQLServer(const char *connection, const char *user, const char *password);
     MSQLServer(const char *link);
+    MSQLServer(TEnv &env, const char *prefix=0);
+    MSQLServer();
     ~MSQLServer();
 
