|
Cross adapter
Few easy steps:
1) On the form/datamodule
where you normally place a TkbmMWNexusDBConnectionPool, leave it there (provided
you still want your application server to be able to connect to NexusDB), but
also put a TkbmMWXConnectionPool, and connection pools for all other
databases/databaseAPI's you want to use and configure them with the needed
connection setups just like if you would use them the normal kbmMW
way.
2) Set the ConnectPool property of the TkbmMWXConnectionPool to
point on the database specific connection pool you want your application to talk
with. This way you can connect the cross adapter to any database specific
connection pool at any time you choose, by setting only one property.
3)
Instead of using TkbmMWNexusDBQuery etc. components on your query services, use
TkbmMWXQuery etc. components. Hook them up to the TkbmMWXConnectionPool, either
via a TkbmMWPooledSession (required in v.1.xx) or directly via the
ConnectionPool property of the components (requires kbmMW v.2).
4) If you
want to have concurrent access to multiple different databases, of which you
want to be able to switch between database types at runtime, simply add multiple
TkbmMWXConnectionPool component, one for each concurrently open
database.
This is about it. Then there are some more interesting things
you can optionally do if you need to:
Macros
Normally you
would define the SQL in the query service's query components. But if the
different databases have different dialects, tablestructure etc. that wont
easily work without some remapping. For this purpose you can use the Macro
property of the database API connection pool. Its a simple string list which
contains elements of the form NAME=DATA. Each name is a macro name, and the data
is anything you can think about.
Thus if one database require you to use
one specific SQL statement to extract the data you need from it, you can put a
macro with that statement in that database's Macro property, and instead of
writing SQL in the TkbmMWXQuery component, refer to the macroname.
Eg. we
have macro:
somesql=select a,b,c from xyz
in the NexusDB connectionpool, and for example:
somesql=select
x+y as a,b,c from xyz
in some other database's connection pool, both statements giving the expected
result for the enduser. Then the TkbmMWXQuery.Query property would be set to:
''
You could have chosen to set the somesql macro like
this:
somesql=a,b,c
and
somesql=x+y,b,c
respectively and the query statement like this:
'select from xyz'
This is equally
valid.
You can have multiple macros in each statement if you want that. You can also
use the macros from the client side. In this case you have a 2 step macro
conversion. First the client will substitute all macros defined on the
TkbmMWClientConnectionPool, then the server will substitute whats left (the ones
not matching on the client side) by whats defined in the database API's
connection pool's macro property.
Macros works not only in combination
with the cross adapter, but also directly with database API adapters.
To
enable the macro replacement, set EnableMacros:=true on the
connection pool.
An event exists, OnUpdateMacros, for you to be able to
update the macro settings you want (for example loading them from a file or
something) when the connection pool is activated if thats needed. For the event
to fire, the AutoUpdateMacros property must be set to true.
Meta
data
kbmMW v2 includes database independant metadata handling. This
is described in one of the whitepapers on the C4D documentation page.
In a nutshell, it allows you to operate generators/sequences/pivot tables,
create/delete/empty etc. tables and create/delete/rebuild indexes without having
to worry about the type of database.
kbmMW takes care of generating the right operations (SQL or not) to make it
happen.
-- best regards Kim Madsen kbm@components4developers.com www.components4developers.com
The
best components for the best
developers kbmMW - RAD
n-tier application server framework kbmMemTable - High performance memory
table kbmWABD - RAD web
development kbmX10
- RAD house automation
(Top)
|