db-derby-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Dyre.Tjeldv...@Sun.COM
Subject Re: Hwo to invoke a modified execute method
Date Wed, 18 Jul 2007 18:24:35 GMT
Dimple Bhatia <dimp20@gmail.com> writes:

> Hi,
> I have overloaded the execute method in
> org.apache.derby.impl.jdbc.EmbedStatement.execute and can call that via a
> test program using the Embedded driver and that works fine.Now I want to run
> Derby in network server mode and want to call this modified execute method
> from the client side. 

In that case you need to patch the NetworkServer to use your
overloaded execute when it makes calls to the embedded driver.

> I see that when i create a client program to execute a
> statement it calls the org.apache.derby.client.am.Statement.execute() which
> calls executeX(sql) which calls flowexecute(). And i think at some time it
> must be callign the EmbedStatment.execute() on the server side.  

Correct. But EmbedStatment.execute() will be called on the sever no
matter what you do in the client.

> So I thought I should overload the
> org.apache.derby.client.am.Statement.execute() methods(since those
> are the methodson the client side).  I tried to overload the
> org.apache.derby.client.am.Statement.execute() method but not sure
> how to change the flowExecute() and get that working. The API seems
> complicated so wondering if anyone has any ideas on how I can do
> this? Not sure if Derby uses RMI(remoe method invocation) under the
> covers when it invokes the execute methods on the server side.

Nope, it uses DRDA (a specialized protocol for database access).  It
is a bit hard to give advice here, since I don't know what your
overloaded execute() method looks like, but I'm guessing that you're
adding parameters. The first thing you need to do is to find a way to
transmit those through DRDA to the server. Then you need detect them
on the sever so that the server code can figure out the execute method
to use, and supply the extra parameters as required.

I don't mean to discourage you, but the DRDA protocol isn't for the
faint of heart (it consists of several thick volumes) and Derby's
implementation of DRDA isn't really that easy to understand either,
I'm afraid. 

It is perhaps easier to get a feel for this if you start at the
sever. Start by looking at DRDAConnThread.processCommands to see how
the NetworkServer converts DRDA to jdbc commands which it passes on to
the embedded engine, and then converts ResultSets (and exceptions) to
DRDA which it sends back to the client).

HTH

-- 
dt


Mime
View raw message