views:

74

answers:

3

I really enjoy the JDBC abstraction in Java. I don't care what database type I am connecting to, or what driver is being used. That's all set up in the DataSource object, and once it's done, we just use connections. It's such a consistent API in order to commit/rollback, perform transactions, and you only need to learn it once, and move on with your life. MySQL/Oracle - no worries, it's all the same (except for the SQL differences)

Four questions: 1. What is the most popular equivalent for c++/c. 2. What is the best? 3. Is there any api that mirrors the java api for connections? Something very similar? 4. I really like the Dao/DaoImpl pattern often employed in Java. Do people do this same pattern in c++.

Thanks guys!

+1  A: 

ODBC it the answer for question 1. (The JDBC API was modeled after ODBC.)

Christian Ullenboom
+1  A: 

The standard for cross platform database connectivity is ODBC. However, this is a very large C API which can take some getting used to (but works well once you are used to it). There are a lot of C++ wrapper libraries for it, but I can't recommend any of them as I've always used my own wrapper. Do a search for "c++ database library" using the SO google search at http://stackoverflow.com/search to see lots of questions on this topic.

anon
A: 

There is no equivalent in C++. ODBC is the closest thing.

However, ODBC is more than a database interface (Call Level Interface), it also defines an underlying connection protocol so you will need a middle-ware or driver on the database server-side to use ODBC.

On the other hand, JDBC is simply a standard programming interface and it can communicate to database using native protocols without any drivers. Some JDBC implementations talks to database through ODBC (so called JDBC-ODBC bridge driver).

ZZ Coder