Oracle 5.0 Reference Manual page 1936

Table of Contents

Advertisement

public virtual bool ExecuteNonQuery(string sql, ref int returnValue);
public virtual bool ExecuteReader(string sql, CommandBehavior behavior, ref MySqlDataReader returnValue);
public virtual void Init(MySqlConnection connection);
If your interceptor overrides one of the
parameter and return
true
SQL command is processed normally only when all command interceptors return false.
The connection passed to the
• The
BaseExceptionInterceptor
encounters a SQL exception. The exception interception mechanism is modeled after the
Connector/J model. You can code an interceptor class and connect it to an existing program without
recompiling, and intercept exceptions when they are created. You can then change the exception
type and optionally attach information to it. This capability lets you turn on and off logging and
debugging code without hardcoding anything in the application. This technique applies to exceptions
raised at the SQL level, not to lower-level system or I/O errors.
You develop an exception interceptor first by creating a subclass of the
BaseExceptionInterceptor
You can also override the
Each exception interceptor has 2 methods:
public abstract Exception InterceptException(Exception exception,
MySqlConnection connection);
public virtual void Init(MySqlConnection connection);
The connection passed to
Each interceptor is required to override
return the exception it is given, or it can wrap it in a new exception. We currently do not offer the
ability to suppress the exception.
Here are examples of using the FQN (fully qualified name) on the connection string:
MySqlConnection c1 = new MySqlConnection(@"server=localhost;pooling=false;
commandinterceptors=CommandApp.MyCommandInterceptor,CommandApp");
MySqlConnection c2 = new MySqlConnection(@"server=localhost;pooling=false;
exceptioninterceptors=ExceptionStackTraceTest.MyExceptionInterceptor,ExceptionStackTraceTest");
In this example, the command interceptor is called
and exists in the
CommandApp
ExceptionStackTraceTest.MyExceptionInterceptor
ExceptionStackTraceTest
To shorten the connection string, you can register your exception interceptors in your
file like this:
web.config
<configSections>
<section name="MySQL" type="MySql.Data.MySqlClient.MySqlConfiguration,
MySql.Data"/>
</configSections>
<MySQL>
<CommandInterceptors>
<add name="myC" type="CommandApp.MyCommandInterceptor,CommandApp" />
</CommandInterceptors>
</MySQL>
<configSections>
<section name="MySQL" type="MySql.Data.MySqlClient.MySqlConfiguration,
MySql.Data"/>
</configSections>
<MySQL>
Connector/Net Programming
Execute...
if you handled the event, or
method is the connection that is attached to this interceptor.
Init
lets you perform additional operations when a program
class. You must override the
method to do some one-time initialization.
Init()
is the connection that is attached to this interceptor.
Init()
InterceptException
CommandApp.MyCommandInterceptor
assembly. The exception interceptor is called
assembly.
1916
methods, set the
returnValue
if you did not handle the event. The
false
InterceptException()
and return an exception. It can
and exists in the
output
method.
or
app.config

Advertisement

Table of Contents
loading

This manual is also suitable for:

Mysql 5.0

Table of Contents