Instructions for using the Database Template Library
- Contents
- When you unpack dtl.zip it should
create the following directories:
- \docs: Documentation and examples
on how to use the Database Template Library. To
read, open the main file called index.htm.
- \lib: This is the main code for
the DTL.
- \example_db: Table definitions and
sample data for the code in the "example"
and "tests" directories.
- \example: Example code for using
the DTL.
- \tests: Regression tests for the
DTL / further examples.
- Getting Started:
- Take a look at the docs files. Be
sure to read "Introduction to the DTL"
as this gives a good overview of the capabilities
of the library.
- Go into the lib directory. Build
the library file (DTL.lib in Windows, dtl.a in
UNIX). To compile from Visual Studio 6.0 open
DTL.dsw. To compile from UNIX type "make"
which will run the "Makefile" in this
directory. (To compile under UNIX you will need
to have unixODBC installed).
- Create the sample database from
the example_db directory.
- If you have a copy of
Access97 there is nothing to do here. We
have a sample Access database in the
example_db directory.
- If you are using Oracle
perform the following steps from SQL*PLUS:
- >create user
example identified by example;
- >grant dba to
example; -- actually we need less
than this, but it's easier to
grant dba
- >connect
example/example;
- >@e:\dtl\example_db\tables.sql
-- run the tables script to
create the example tables
- >@e:\dtl\example_db\data.sql
-- insert sample data into the
example tables
- If you are using MySQL
perform the following steps:
- create a user
called "example" with
password "example".
- >mysql
<database_name> -u example
< tables.sql -- run the tables
script to create the example
tables
- >mysql
<database_name> -u example
< data_mysql.sql -- insert
sample data into the example
tables
- Create an ODBC data source called
"example" from the ODBC Data Source
Administrator tool in the control panel:
- The example code uses the
following ODBC connect string: "UID=example;PWD=example;DSN=example;";
Therefore it connects as user "example",
password "example" to the ODBC
data source named "example". We
assume that the user and password are
already set up as explained above &
show how to set up the data source name.
- Choose the tab labeled
"System DSN". Choose "Add
--> Microsoft Access Driver (*.mdb)".
For the data source name enter "example"
and choose the file called example.mdb in
the example_db directory. (If you prefer
to use Oracle choose the Oracle ODBC
driver and enter your SQL*NET connect
string etc.)
- Build and run the example code.
- Go to the directory called
\example. Open the file example.dsw and
build from VC++ 6.0 to create the example
executable. (Or run "make" from
the example directory if you are working
under UNIX).
- Using the library in your own code:
- To use the library in your own
code you will need to do two things:
- Include the \lib directory
in the include (\I) path for your
compiler.
- Include the library file (DTL.lib
or dtl.a) in the set of files that you
link to in producing your executable.
- Release Notes
- Version 2.0
- Added support for SGI's
STLPort implementation of the Standard
Template Library.
- Successfully ported code
to Red Hat Linux 7 under gcc 2.95 running
unixODBC and a MySQL 3.23.33 database.
- Corrected constness
throughout DTL.
- Rewrote the code to make
it exception safe.
- Added error handling
support for all DTL iterator classes,
DBView, and IndexedDBView in the form of
IOHandler.
- Iterator refinements:
- DB_select_iterator::operator*()
now returns
a const DataObj
& to
make that operation truly read-only.
- All output
iterators now use proxies to
emulate *it = value to
enforce
their write-only quality.
- Also fixed prefix/postix
implementation for operator++()
on all
iterators.
- Enhanced DBConnection class to use ODBC connection
pooling.
- Added Julian date support through
the jtime_c class.
- Notes for Linux.
- The MySQL ODBC driver version
2.50.36-1 on Linux does not work
correctly with SQLPrepare(). Current workaround involves calling SQLExecDirect() rather than SQLPrepare(). To compile with this workaround define
the symbol MYODBC_BUG as described in the makefile. (Another alternative is to
download the source for MyODBC and re-compile. On the test machine
we used this also seemed to fix the problem.)
- MySQL 3.23.33 does not support
COMMIT or ROLLBACK. Therefore the "range
transaction" examples will not work under
this version MySQL.
- When you run the executable for
the first time under unixODBC you may get a message
like "error while loading shared libraries:
libodbc.so.1: cannot open shared object file:
No such file or directory". The problem in this case is not
having your environment variables set up
correctly for unixODBC.
From: "Nick Gorham" <nick@lurcher.org>
To: <cjoy@houston.rr.com>
Subject: unixODBC
> Hi,
>
> Your problem is not finding the lib at
compile time, but at run time,
> either add /usr/local/lib to LD_LIBRARY_PATH
>
> LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/lib
> export LD_LIBRARY_PATH
>
> (the above assumes linux, if some other OS,
it's much the same, mail me
> if you can't find the variable)
>
> Or in linux, as root you can add /usr/local/lib
to /etc/ld.so.conf, and
> then run ldconfig (often in /sbin/ldconfig),
to add it to all users lib
> search paths.