C++ equivalence of JDBC

K

Kira Yamato

I apologize if this is an off topic question, but I am not sure where
is the right forum to ask this:

I was wondering what are the currently popular choices for database
connectivity in C++.

Is there a standard being worked on that will become the C++
equivalence of java's JDBC?

Thanks.
 
A

Alf P. Steinbach

* Kira Yamato:
I apologize if this is an off topic question, but I am not sure where is
the right forum to ask this:

I was wondering what are the currently popular choices for database
connectivity in C++.

Is there a standard being worked on that will become the C++ equivalence
of java's JDBC?

You might check out

<url:
http://pocoproject.org/poco/wiki/tiki-index.php?page=DataQuickStart>

I haven't used it.

Please, if you do check it out, report on your experience so that others
on this group can benefit.


Cheers, & hth.,

- Alf
 
E

Erik Wikström

I apologize if this is an off topic question, but I am not sure where
is the right forum to ask this:

I was wondering what are the currently popular choices for database
connectivity in C++.

Is there a standard being worked on that will become the C++
equivalence of java's JDBC?

ODBC have been standardised since 1992.
 
J

James Kanze

On 2008-01-26 11:02, Kira Yamato wrote:
ODBC have been standardised since 1992.

So all he has to do is find a library which implements it:).

I used OTL (http://otl.sourceforge.net/home.htm) in one previous
project. I'm not sure I totally agree with the philosophie, but
it did work out pretty well. No support for any of the free
databases (mySQL, PostgreSQL, etc.), however (at least as far as
I can tell).
 
P

Phil Endecott

Kira said:
I apologize if this is an off topic question, but I am not sure where is
the right forum to ask this:

I was wondering what are the currently popular choices for database
connectivity in C++.

Is there a standard being worked on that will become the C++ equivalence
of java's JDBC?

There's something called ODBC which is supposed to be the equivalent.
I've not used it. In my experience, almost any non-trivial SQL
application will use implementation-specific features; once you're in
this situation you may as well use a database-specific access library.

My own attempt at turning SQL queries into C++ functors for PostgreSQL,
implemented on top of the PostgreSQL C API, can be found here:

http://svn.chezphil.org/libpbe/trunk/include/Database.hh

It lets you declare queries something like this:

SingletonQuery<string, int>
get_user_name_from_id(db,"select name from users where id=$1");

The template parameters to Query are the result and parameter types
respectively. You can then invoke it as a functor:

string n = get_user_name_from_id(1234);

The query is prepared when declared and invoked using PostgreSQL's
binary API, so there's no serialisation/deserialisation going on between
the application and the database. We also get reasonably strong type
checking.


Regards, Phil.
 
J

Jerry Coffin

[ ... ]
I used OTL (http://otl.sourceforge.net/home.htm) in one previous
project. I'm not sure I totally agree with the philosophie, but
it did work out pretty well. No support for any of the free
databases (mySQL, PostgreSQL, etc.), however (at least as far as
I can tell).

Unless I'm misunderstanding its documentation completely (I'll admit I
haven't put this part to the test) it's supposed to be able to deal with
anything that has an ODBC compliant driver -- which nearly all the free
databases do. It also has native support (i.e. no driver needed) when
talking to a few specific databases (Oracle, db2, etc.)
 
K

Kira Yamato

So all he has to do is find a library which implements it:).

I used OTL (http://otl.sourceforge.net/home.htm) in one previous
project. I'm not sure I totally agree with the philosophie, but
it did work out pretty well. No support for any of the free
databases (mySQL, PostgreSQL, etc.), however (at least as far as
I can tell).

Looks promising. From what I can see so far, it integrates well with
STL (supports std datatypes as well as std iterators). The FAQ also
says it works with mySQL too.

Thanks for the suggestion.
 
J

James Kanze

[ ... ]
I used OTL (http://otl.sourceforge.net/home.htm) in one previous
project. I'm not sure I totally agree with the philosophie, but
it did work out pretty well. No support for any of the free
databases (mySQL, PostgreSQL, etc.), however (at least as far as
I can tell).
Unless I'm misunderstanding its documentation completely (I'll admit I
haven't put this part to the test) it's supposed to be able to deal with
anything that has an ODBC compliant driver -- which nearly all the free
databases do. It also has native support (i.e. no driver needed) when
talking to a few specific databases (Oracle, db2, etc.)

Maybe. It's been five or six years since I used it, and we were
only interested in Oracle. (In other words, don't take anything
I say about it, other than it existed once, as a certain truth.
In particular, you might want to check whether it is still being
actively maintained, etc.---all the usual things you have to
check before using an open source library.)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,582
Members
45,057
Latest member
KetoBeezACVGummies

Latest Threads

Top