#52 ADONET Appender using Oracle

open
nobody
None
5
2003-09-29
2003-09-29
Anonymous
No

I posted to the user group a while back about a problem
I am having with the ADONET Appender. I am not sure
whether this is my error or a bug of log4net. I
followed the example in the documentation to create a
table in my Oracle database (on both 9i and 8i)and an
ADONET appender. However when I ran my app I get
different errors in the internal debug depending on my
versions of Oracle and Oracle Client. (see the errors at
the end of the message) Is this a log4net bug? Do you
know anyone who is using an ADONET appender with
Oracle? I am attaching my test application.

Any help you could provide would be greatly appreciated.

Thanks,
Blossom Coryat
bcoryat@msn.com

in the following instances:

Using Oracle 9i and connection type= <param
name="ConnectionType"
value="System.Data.OracleClient.OracleConnection,
System.Data.OracleClient, Version=1.0.3300.0,
Culture=neutral, PublicKeyToken=b77a5c561934e089" />

Using Oracle 9i and connection type= <param
name="ConnectionType"
value="System.Data.OracleClient.OracleConnection,
System.Data.OracleClient, Version=1.0.5000.0,
Culture=neutral, PublicKeyToken=b77a5c561934e089" />

Using Oracle 8i and connection type = <param
name="ConnectionType"
value="System.Data.OracleClient.OracleConnection,
System.Data.OracleClient, Version=1.0.5000.0,
Culture=neutral, PublicKeyToken=b77a5c561934e089" />

Error:
log4net:ERROR [ADONetAppender] Could not open
database connection [data source=cds;User
ID=cds_user;Password=cd1temp]
System.InvalidCastException: Specified cast is not valid.
at
log4net.Appender.ADONetAppender.InitializeDatabaseCon
nection() in c:\documents and settings\blossom
coryat\desktop \log4net-1.2.0-beta8\log4net-1.2.0-
beta8\src\appender\adonetappender.cs:line 502
log4net: DOMConfigurator: Created Appender
[ADONetAppender_Oracle]
log4net: DOMConfigurator: Adding appender named
[ADONetAppender_Oracle] to logger [root].
log4net: DOMConfigurator: Hierarchy Threshold []

I get this error when I use use Oracle 8i and
ConnectionType= <param name="ConnectionType"
value="System.Data.OracleClient.OracleConnection,
System.Data.OracleClient, Version=1.0.3300.0,
Culture=neutral, PublicKeyToken=b77a5c561934e089" />

log4net:ERROR [ADONetAppender] Exception while
writing to database
System.Data.OracleClient.OracleException: ORA-12704:
character set mismatch

at
System.Data.OracleClient.OracleConnection.CheckError
(OciHandle errorHandle, Int32 rc)
at System.Data.OracleClient.OracleCommand.Execute
(OciHandle statementHandle, CommandBehavior
behavior, Boolean isRead er, Boolean needRowid,
OciHandle& rowidDescriptor, ArrayList&
refCursorParameterOrdinals)
at System.Data.OracleClient.OracleCommand.Execute
(OciHandle statementHandle, CommandBehavior
behavior, Boolean needRo wid, OciHandle&
rowidDescriptor)
at
System.Data.OracleClient.OracleCommand.ExecuteNonQu
eryInternal(Boolean needRowid, OciHandle&
rowidDescriptor)
at
System.Data.OracleClient.OracleCommand.ExecuteNonQu
ery()
at log4net.Appender.ADONetAppender.SendBuffer
(IDbTransaction dbTran, LoggingEvent[] events)
at log4net.Appender.ADONetAppender.SendBuffer
(LoggingEvent[] events)

-------------------------------------------
I got the ADONet Appender to work but
I changed the InitializeDatabaseConnection method of
the ADONETAppender and Created a temp
oracleConnection to create the connection object (see
the method below)

I don't want to change the source code for
ADONetAppender. Is there a better way to do this or is
there something wrong with my enviroment?

Thanks,
Blossom Coryat

virtual protected void InitializeDatabaseConnection()
{

System.Data.OracleClient.OracleConnection
oraConn = new OracleConnection();

try
{

// Create the
connection object
//
m_dbConnection =(System.Data.IDbConnection)
Activator.CreateInstance(ResolveConnectionType());
m_dbConnection =
(System.Data.IDbConnection)oraConn;

// Set the
connection string

m_dbConnection.ConnectionString =
m_connectionString;

// Open the
database connection

m_dbConnection.Open();

}
catch (System.Exception e)
{
// Sadly, your
connection string is bad.
ErrorHandler.Error
("Could not open database connection [" +
m_connectionString + "]", e);
}
}

Discussion