|
Home > Archive > SQL Anywhere ultralite > February 2006 > question: how to share connection in combined static and dynamic
You are viewing an archived Text-only version of the thread.
To view this thread in it's original format and/or if you want to reply to
this thread please [click here]
| Author |
question: how to share connection in combined static and dynamic
|
|
| Michal Seliga 2006-02-25, 9:41 am |
| hi
this is from docs:
---
To share a single connection
1. Ensure that your application is sharing a single SQLCA, as described in
the previous procedure.
2. Manage the connection using the UltraLite C++ Component.
Use the DatabaseManager::Ope
nConnection and Connection::Release
methods to open and close connections. Do not use the static interface
connection mechanisms. Once OpenConnection returns, the connection is current
for the SQLCA and is used for any subsequent embedded SQL or static C++ API
statements.
---
i did this but i have problem - all generated classes in uldatabase.cpp require
ULConnection as first parameter of Open (or Execute) methods. when i create
connection using ultralite c++ component what should i send there? NULL doesn't
work...
so question is, how can i get ULConnection pointer when i manage connections
with DatabaseManager object?
thanks in advance...
| |
| Michal Seliga 2006-02-25, 9:41 am |
| thank you for answer, i will test it.
Michael Thode wrote:
> If you don't need your static and dynamic UL code to be part of the same
> transaction then you can create a separate connection to the database for
> each API. This is the easiest route. UL runs at isolation level zero, so
> uncommitted rows on one connection _will_ be visable on the other
> connection. The only thing you can't do is insert/update a row on one
> connection (without committing it) and then try and update/delete it on
> another connection.
>
> If that doesn't work for you and you need to share the connection then that
> isn't officially supported in UL. The docs appear to be misleading here.
> For sharing a connection mixing dynamic C++ API with ESQL is ok, but not
> dynamic C++ and static C++.
>
> Unofficially you can get the functionality you need by altering
> %asany9%\src\ulapi.cpp and %asany9%\h\ulapi.h
>
> Add the following method to ulapi.cpp. This will allow you to initialize a
> ULConnection object from an existing connection.
>
> bool ULConnection::Attach
( ULData *db, ul_char *name )
> {
> if( db == UL_NULL ) return false;
> if( !db->IsOpen() ) return false;
> if( IsOpen() ) return false;
> _db = db;
> _conn = ulpp_setconnect( db->GetCA(), name ); // This line is the
> difference between Attach and Open
> _open = LastCodeOK();
> return _open;
> }
>
> Then add the corresponding prototype in ulapi.h in the public section of the
> ULConnection class (about line 240 in my copy of the file)
>
> In order to make this work....
> 1. Share your sqlca as described in the docs
> 2. Connect using dynamic C++. Name your connection eg add
> "CON=myconnection" to the connection parameters
> 3. Call the new Attach method using the connection name
>
> Note:
> Don't call ULConnection::Close on the shared connection, use the dynamic C++
> API to close the connection.
> Make sure to you make copies of the new ulapi files. They could be
> overwritten by an EBF.
>
> Hope that helps,
> Mike
>
> "Michal Seliga" <michal.seliga@visicom.sk> wrote in message
> news:43fdddd2$1@foru
ms-2-dub...
> current
> API
> require
> create
> doesn't
> connections
>
>
|
|
|
|
|