[odb-users] Multi-Database Support - Cannot integrate Multi-Database Support / Bug report for the compiler: odb-2.2.1-i686-windows

Benjamin Schudel benjamin.schudel at nexirius.com
Tue May 21 08:03:18 EDT 2013


Hello,



I have some problems to integrate the Multi-Database support in my
application.

The goal that I pursue is the possibility to switch between different
database-systems at runtime (sqlite, mssql and mysql).

At the moment the application supports only sqlite.

I tried a lot of opportunities as described in the manual, without success.

Is there a working example of a Multi-Database support application
available?



What I did:



-          First I tried to integrate dynamic multi-database support.  For
that I generated the ODB-Files for my perstistable business objects with
the following command:

odb.exe -m dynamic -d common -I C:\Qt\qt-5.0.1-32-dyn\qtbase\include
--profile qt *.h  (compiler: odb-2.2.1-i686-windows)

The source code compiled without changes, but during the first odb call I
got an exception (Unhandled exception at 0x0033FE4B in Gui.exe: 0xC0000005:
Access violation reading location 0x00000000.). The sourcecode looks like
this (sqlite example -  this code workes with single database compiled
odb-files ):



#include <odb/sqlite/database.hxx>

#include "User-odb.hxx"



…



shared_ptr<odb::database> db (new odb::sqlite::database(
"../../Bom1/bom1.sqlite", SQLITE_OPEN_READWRITE | SQLITE_OPEN_URI));

typedef odb::query<User> userQuery;

       typedef odb::result<User> result;

{

                                odb::transaction t (db->begin ());

             result user (db->query<User>(userQuery::name == username));



…



t->commit ();

                }



I tried a lot of other constellations e.g. typedef odb::sqlite::query<User>
userQuery; and odb::sqlite::transaction t (db->begin ()); but all ends with
a compile error.

       What did I wrong? Can you send me a working example?



-          In a second step I tried to implement the static multi-database
support. For that I generated the ODB-Files for my perstistable business
objects with the following command (sqlite example):

odb.exe -m static -d sqlite -I C:\Qt\qt-5.0.1-32-dyn\qtbase\include
--profile qt *.h (compiler: odb-2.2.1-i686-windows)

       Unfortunately, I realized that the generated source code cannot be
compiled. Each .cxx file contains an Error. E.g. in the User-odb.sqlite.cxx
file two includes are on the same line:

                #include "UserGroup-odb-sqlite.hxx"#include
"User-odb.hxx" àI think that’s a bug in the compiler, or did I
something wrong?

                Once I changed all generated files by hand , the source
code compiled, but even in the static mode I didn’t get it to run.

I included the "User-odb-sqlite.hxx" file instead of the "User-odb.hxx" file
and tried again many different constellations, but it always ends in a
compile error or in a Unhandled exception…



The following modules I’m using:

-          libodb-2.2.2

-          libodb-qt-2.2.0

-          libodb-sqlite-2.2.0

-          libodb-mssql-2.2.0

-          libodb-mysql-2.2.0



I hope somebody can help me, and/or send me a complete, working example.



Thanks in advance,



Benjamin Schudel


More information about the odb-users mailing list