dtl
Which compilers are supported?
The DTL has been tested on these compilers:
Microsoft Visual C++ 6.0, service pack 5, using Windows NT 2000
Microsoft Visual C++ 7, using Windows NT 5
Microsoft Visual C++ 2005 Express, under Windows NT 2000
Borland 5.5, 6.0 under Windows NT 2000
GNU C++ 3.2 using Red Hat Linux 7 with unixODBC 2.0.8
GNU C++ 3.3 using Cygwin and Microsoft ODBC DLLs
GNU C++ 2.95.4 under FreeBSD with STLPort (as reported by R. Kotha).
Sun Solaris Workshop 6, Update 1 using the Merant 3.7 ODBC drivers (we are not currently testing this compiler)
HP with aCC A.03.35 using the Merant 3.7 ODBC drivers (we are not currently testing this compiler)
Which databases are supported?
We have followed the ODBC 3.0 standard and done nothing database specific. So any database that has on ODBC 3.0, Level 1 compliant
driver should work. The databases we regularly test against are:
Oracle 8, 9
SQL Server 2000
Access 2000
MySQL
We have also had reports that others have successfully used DTL against Sybase, Postgres and DB2.
(Please note, as reported by Ben Martin, that if you are using Postrgres versus unixODBC then
you should use the official Postgres driver from http://gborg.postgresql.org/project/psqlodbc/projdisplay.php
since the one that comes with unixODBC does not work with DTL).
If you succeed in using the DTL with some other compiler or database, please let us know, and please tell us what modifications (if any) you had to make.
How do I install the DTL?
You should unpack the DTL include files in a new directory, and
then use the -I (or /I) option to direct the
compiler to look there first. You will need to compile and link
to the library file that we generate. See the Readme.htm that comes
with the installation for details
Is the DTL Y2K compliant?
Yes, to the degree that the underlying database it is reading
from is Y2K compliant. The DTL reads into the standard ODBC
timestamp structure. Since DTL does not manipulate this date in
any way, the resulting time strucutre will be correct as long as it comes
from the database correctly. In addition, DTL provides date math functions through the
use of an optional jtime_c structure. These functions will process dates
both before and after the year 2000 correctly.
See jtime_c for details.
Can I build DTL as a DLL and just link to it?
No, you cannot. DTL is a template library. This means that the code
gets instantiated and customized based on the classes you supply. Therefore you cannot simply
build DTL as a DLL library, the code is largely in the templates / header files.
When I call DTL from a DLL, sometimes I get an error when the DLL exits?
In principle, the C++ global destructors should correctly release the environment.
In practice, sometimes these destructors get called after the ODBC connection
has been dropped which may cause an error. To handle this, it is best to
place the following in your finalize routine for the DLL:
void finalize()
{
if(dtl::DBConnection::GetDefaultConnection().IsConnected())
{
dtl::DBConnection::GetDefaultConnection().Release();
dtl::DBConnection::GetDefaultEnvironment().Release();
}
}
What is the roadmap for future development of DTL?
The top ones on my wish list would be (in order of when we are likely to get to them):
1. Improve the internals documentation - give more explanation of the design behind DTL.
Do you have any plans to add support for native drivers?
Not any time soon. The primary reason for doing this would be performance. We have tried to encapsulate all of the ODBC
calls in three classes called DBStmt, DBConnection and DBEnvironment so we could bind to a native driver should we so desire. In practice, this is not a priority for us since ODBC gives us good database portability and
my belief is that, used properly, ODBC is just as fast (or faster!) than native drivers. The real key is
knowing how to use the ODBC API effeciently by e.g. not re-connecting for each query, using bulk inserts to
send large data sets, using forward only cursors to do simple reads and so on. As much as possible we have tried
to use ODBC "best practices" in DTL so that we make efficient use of the API and code the uses DTL will be fast. We also provide a simple
performance benchmark and "profile" project
that we have used to track the overhead that DTL imposes above and beyond the ODBC API. Here are links
to benchmarks that have been done to compare ODBC versus native drivers.
Overview of ODBC perfomance v.s. native drivers and list of references
ODBC v.s. native driver benchmarks
More discussion of ODBC versus native drivers
Does DTL support multi-threading?
There are a number of projects using DTL in a multi-threaded fashion
and I believe DTL to be fairly thread safe when objects are not
shared across threads as described in the first method below.
However, we are not threading experts so we need to have
our work reviewed by someone who is more of an expert to make sure we have
not missed anything.
** The easiest way to use DTL in a multi-threaded context is to have each
thread operate on its own connection and not share any containers or iterators
across threads. This should be fairly safe since:
1. You should be able to get an ODBC driver that is multi-thread safe for
independent connections.
2. We have been very careful in DTL to avoid static variables. The only exceptions
are:
a. DefaultConnection - is static. b. The base ODBC environment - is static and allocated upon the first connection (this default environment also initializes any global statics used by the library).
DBView::select_iterator it1 = view.begin(); DBView::select_iterator it2 = view.begin(); it3 = i2; it1, it2 and it3 will all get a seperate HSTMTs.The underlying ODBC API should ensure that calls against these seperate HSTMTs will be thread safe so as long as each thread has its own iterator(s) to work against they should be safe.
EnterCriticalSection(); if (bFetched) { LeafeCriticalSection(); return; ... fetch here... LeaveCriticalSection();4. RandomDBView
Copyright © 2002, Michael Gradman and Corwin Joy.
Permission to use, copy, modify, distribute and sell this software and its documentation for any purpose is hereby granted without fee, provided that the above copyright notice appears in all copies and that both that copyright notice and this permission notice appear in supporting documentation. Corwin Joy and Michael Gradman make no representations about the suitability of this software for any purpose. It is provided "as is" without express or implied warranty.