Thanks by the help! I will study the best solution to my problem! On Tue, Apr 22, 2008 at 10:49 PM, Thomas Hruska <[EMAIL PROTECTED]> wrote:
> Rodrigo Bortholin wrote: > > Hi, > > > > I need to do a Layer of database acess to my program, this layer need to > > acess the most kind of database( mysql, postgreSQL, sql, etc...) > > > > Do you know if there is a component or a lib that do it ? > > > > > > Thanks, > > Rodrigo > > "How do I use a database in C/C++?" is a very common question on c-prog > that has been answered countless times. It usually starts out with > someone asking the question and the first response is almost always a > database-specific answer that rarely answers the question. People are > fascinated with Relational DataBase Management Systems (RDBMS'), perhaps > even enamored. Whatever the case may be, there are two different > approaches to database integration in C/C++ that you can take. > > The first approach that you can take is the "I am writing code for one > database product only and could care less about cross-platform > possibilities for my application" approach. This approach locks you > into a single database vendor. Depending on the vendor, this may or may > not be a good thing. While it may not be a cross-platform friendly > approach, it does allow you to use database specific optimizations to > garner a big boost in application performance that you might not get > otherwise. > > The second approach that you can take is the "I am writing code for all > popular database products in existence" approach. This frees you from > being locked into a single database vendor. The downside is that the > application will probably take a significant performance hit for being > database-neutral. > > For the first approach, you need to pick a database and stick with it. > Choose carefully because you will probably end up using that database > product for decades. Oracle, IBM DB2, and Microsoft SQL Server are the > big commercial vendors in this realm. The big free and open source > databases are MySQL and PostgreSQL. However, keep in mind that there > are hundreds, if not thousands, of database products out there. > > Any major database worth its salt has libraries that you can link > against with a modern C/C++ compiler. These libraries have APIs that > you can use in your code. Since each database has different APIs, you > will have to read the documentation on the APIs for your database before > writing code to understand what you need to do when you do write code. > It is highly recommended that you join a user community dedicated to > helping other people out who use the same database product as c-prog > members will likely be unable to help you. > > For the second approach, there are various API wrappers that help > generalize database access. Some people will recommend Windows-specific > APIs such as OLE DB and ADO. Those are Microsoft technologies and lock > your application into a single platform - Windows. ODBC, which stands > for Open DataBase Connectivitiy, is the only cross-platform high-level > database programmatic interface that every major vendor supports and > every major platform supports. There are two downsides to ODBC: The > ODBC APIs are generally difficult to deal with because of the generic > way it treats databases. Also, because ODBC abstracts the connectivity > layer, creating and managing connections to the underlying database is > more difficult. > > So far this probably has been more informative than helpful. c-prog > maintains a set of links for people who want to do non-ANSI Standard > programming in C/C++ on the c-prog website: > > > http://tech.groups.yahoo.com/group/c-prog/links/Non_ANSI_Standard_De_001114214368/Databases_001114218004/ > > Those are links to a whole bunch of different database products. > > To get started with the database product you choose, search Google for > '{databasename} tutorial c++'. Note that anything you find on the > Internet is going to be full of holes larger than a round of swiss > cheese itself - the holes usually being of the database security > variety. But for educational purposes, you've got to start somewhere. > Obviously find the manual for the database product and read it too. > > What do I recommend? ODBC. Every major RDBMS vendor (even Oracle) has > a ODBC driver for their database and it is usually just a lightweight > wrapper around their APIs. You write code once and never have to look > at it again (assuming you write it correctly) versus having to write a > whole bunch of code for each and every database product you use. > > -- > Thomas Hruska > CubicleSoft President > Ph: 517-803-4197 > > *NEW* MyTaskFocus 1.1 > Get on task. Stay on task. > > http://www.CubicleSoft.com/MyTaskFocus/<http://www.cubiclesoft.com/MyTaskFocus/> > > > [Non-text portions of this message have been removed]
