Oracle.DataAccess.Client.OracleException - <Fehler: eine Ausnahme vom Typ: {System.NullReferenceException} aufgetreten> string
Ich brauche Ihre Hilfe, um diesen Fehler zu beheben passiert, wenn Sie versuchen, öffnen Sie die oracle-Verbindung in die Datenbank. Connection.Open ();
ConnectionString-Wert:
"Data Source=dbora1;Max Pool Size=50;Min Pool Size=1;Connection Lifetime=120;Enlist=true;User Id=slu;Password=slu_4d332;" string
Ausnahme ist null und strack trace ist wie folgt:
StackTrace "
at Oracle.DataAccess.Client.OracleException.HandleErrorHelper(Int32 errCode, OracleConnection conn, IntPtr opsErrCtx, OpoSqlValCtx* pOpoSqlValCtx, Object src, String procedure)
at Oracle.DataAccess.Client.OracleException.HandleError(Int32 errCode, OracleConnection conn, IntPtr opsErrCtx, Object src)
at Oracle.DataAccess.Client.OracleConnection.Open()
at Oracle.DataAccess.Client.OracleConnection.Open()
at Microsoft.Practices.EnterpriseLibrary.Data.Oracle.OracleDatabase.OpenConnection() in c:\\v\\enterpriselibrary\\front_end\\fuentes\\data\\oracle\\oracledatabase.cs:line 444" string
Sie auch Links einen Bild der Schnellansicht von der variable, die erfasst die exepcion.
Hier ist der vollständige code für die Initialisierung der Verbindung zur Datenbank:
protected override IDbConnection OpenConnection()
{
OracleConnection connection = (OracleConnection)GetConnection();
try
{
//Test the connection context mark.
if ( connection.State == ConnectionState.Closed )
{
connection.Open();
}
this.instrumentation.ConnectionOpened(ConnectionStringNoCredentials);
return connection;
}
catch (System.ObjectDisposedException)
{
connection = (OracleConnection)GetConnection( true );
try
{
connection.Open();
return connection;
}
catch
{
connection.Close();
throw;
}
}
catch(System.InvalidOperationException e)
{
//Log in eventviewer
LogConnectionPoolTimeOutEvent(e);
connection.Close();
this.instrumentation.ConnectionFailed(ConnectionStringNoCredentials);
throw;
}
catch (System.OutOfMemoryException)
{
connection.Close();
this.instrumentation.ConnectionFailed(ConnectionStringNoCredentials);
throw;
}
catch(Exception ex)
{
connection.Close();
this.instrumentation.ConnectionFailed(ConnectionStringNoCredentials);
throw;
}
}
Und die Methode code GetConnection () ist:
public override IDbConnection GetConnection()
{
return GetConnection( false );
}
protected IDbConnection GetConnection( bool renew )
{
IDictionary connectionHolder;
OracleConnection tempConn;
//Test the connection context mark.
if ( ConnectionContext.CachedConnectionContext )
{//If the mark is in the callcontext
//Get the connection holder
connectionHolder = CallContext.GetData(ConnectionContext.CALLCONTEXTKEY) as IDictionary;
//If the connection holder does not exists
if ( connectionHolder == null )
{
//create a conection holder
connectionHolder = new Hashtable();
//create the initial connection
tempConn = new OracleConnection(base.ConnectionString);
//add the connection to the holder
connectionHolder.Add(base.ConnectionString, tempConn);
//save the holder in the call context
CallContext.SetData(ConnectionContext.CALLCONTEXTKEY, connectionHolder);
}
else
{
//get the connection from the holder
tempConn = connectionHolder[base.ConnectionString] as OracleConnection;
if ( tempConn == null )
{ //if the connection was not in the holder
//create a new connection
tempConn = new OracleConnection(base.ConnectionString);
//add the connection to the holder
connectionHolder.Add(base.ConnectionString, tempConn);
}
else
{ //if the connection exists
if ( renew )
{ //if should renew the connection
//TODO:Delete
HealthModel.Trace.TraceToken token = HealthModel.Trace.TraceHelper.Start( "+++++++ R e n e w", "", "", 0 );
//closes the connection
tempConn.Close();
//create a new connection
tempConn = new OracleConnection(base.ConnectionString);
//add the connection to the holder
connectionHolder[base.ConnectionString] = tempConn;
//TODO:Delete
HealthModel.Trace.TraceHelper.End( token );
}
}
}
}
else
{//if the mark was not in the call context
//create a connection
tempConn = new OracleConnection(base.ConnectionString);
}
return tempConn;
}
Ich hoffe Ihr könnt mir helfen.
Grüße
Juan Pablo.
Können Sie bitte zeigen Sie den vollständigen code, wo Sie initialisieren und öffnen Sie die Verbindung?
Ich habe gerade den angeforderten code. Ich danke Ihnen sehr, Wernfried!
Was ist
Ich habe gerade den code von GetConnection damit Sie es überprüfen können.
Ich habe gerade den angeforderten code. Ich danke Ihnen sehr, Wernfried!
Was ist
GetConnection()
? Ich nehme an, es gibt null
die den Fehler verursachen.Ich habe gerade den code von GetConnection damit Sie es überprüfen können.
InformationsquelleAutor Juan P. Solari | 2016-03-16
Du musst angemeldet sein, um einen Kommentar abzugeben.
Warum verwenden Sie den
IDbConnection
- Schnittstelle?Einfach versuchen, diese:
InformationsquelleAutor Wernfried Domscheit
Werfried
Ändere ich einfach meinen code nicht verwenden, um nicht die Schnittstelle, aber der Fehler besteht weiterhin.
Stellvertretender Ausnahme Bild
StackTrace:
Vielen Dank für Ihre Zeit
InformationsquelleAutor Juan P. Solari