question: how to share connection in combined static and dynamicultralite? - 02-23-2006 , 11:13 AM
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::OpenConnection 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
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
so question is, how can i get ULConnection pointer when i manage connections
with DatabaseManager object?
thanks in advance...
Re: question: how to share connection in combined static and dynamicultralite? - 02-23-2006 , 11:26 AM
just for case it will be neede, i have asa 184.108.40.20649, i use c++ api on palm
with codewarrior 9.3
Re: question: how to share connection in combined static and dynamic ultralite? - 02-23-2006 , 03:22 PM
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
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();
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
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,
"Michal Seliga" <michal.seliga (AT) visicom (DOT) sk> wrote
Re: question: how to share connection in combined static and dynamicultralite? - 02-24-2006 , 03:34 AM
thank you for answer, i will test it.
Michael Thode wrote: