[C#][Oracle] Account locked
Bonjour,
J'ai un souci avec une OracleConnection sur compte locké. En effet, j'utilise une Oracle connection dans une boucle. La première connexion est valide et le programme se connecte bien à Oracle pour executer la requête. La seconde connexion par contre utilise un compte locké. Aucune exception n'est remonté et le programme utilise la première connexion pour se connecter à la base Oracle.
Voici le code :
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64
| foreach (DataBaseXMLQuery query in ldq)
{
if (query.IsActive)
{
logger.Info("Create Connection #" + listOfConnection.Count);
HasDbSessionAvailable = false;
while (!HasDbSessionAvailable)
{
try
{
myConnection = new OracleConnection(GenQuartzDBConst.GetConnectionString(query.DBType));
myConnection.Open();
HasDbSessionAvailable = true;
}
catch (OracleException e)
{
// ORA-02391 : exceeded simultaneous SESSIONS_PER_USER limit
if (e.Number == 2391)
{
logger.Info(string.Format("No more session available on {0}", myConnection.DataSource));
HasDbSessionAvailable = false;
logger.Info("Wait 30 secondes and new attempt to connect...");
Thread.Sleep(30000);
}
else
{
logger.Info(string.Format("Unable to open connection : {0}", myConnection.ConnectionString));
throw new OracleException(e.ErrorCode);
}
}
}
listOfConnection.Add(listOfConnection.Count, myConnection);
if (!dictionaryOfConnection.ContainsKey(myConnection.ConnectionString))
{
dictionaryOfConnection.Add(myConnection.ConnectionString, 1);
}
else
{
dictionaryOfConnection[myConnection.ConnectionString]++;
}
DataBaseXMLQuery myQuery = query;
string s = myQuery.Reason;
Thread myThread = new Thread(delegate()
{
int connectionNumber = listOfConnection.Count - 1;
logger.Info(string.Format("Execute : {0} on {1} database on connection #{2}", s, query.DBType, connectionNumber));
ExecuteQueryToExplain(listOfConnection[connectionNumber], ref myQuery);
logger.Info("Destroy Connection #" + connectionNumber);
dictionaryOfConnection[listOfConnection[connectionNumber].ConnectionString]--;
listOfConnection[connectionNumber].Close();
listOfConnection[connectionNumber].Dispose();
});
myThread.Start();
listOfThread.Add(myThread);
Thread.Sleep(1000);
}
} |
J'aimerais pouvoir catcher une exception lorsque la tentative de connexion utilise un compte locké. Quelqu'un a-t-il déjà rencontré ce problème ou a-t-il une idée ?
Merci d'avance