![]() ![]() Provides native driver and library: libmysqlclient as an interface between the application and the database. MySQL Database Server will be our back-end database To sum up, you’ll basically need at least the following software. Consult the MySQl C API manuals for more details on these and other APIs. There are many other functions, but these are the functions we shall use when creating the application down the line. Close the Connection void mysql_close(MYSQL *connection) Error Handling unsigned int mysql_errno(MYSQL *connection) char *mysql_error(MYSQL *connection) 6. Functions to Use for Data Retrieval MYSQL_RES *mysql_use_result(MYSQL *connection) MYSQL_ROW mysql_fetch_row(MYSQL_RES *result) 5. Execute SQL Statements int mysql_query(MYSQL *connection, const char *query) 4. Make the Connection MYSQL mysql_real_connect( MYSQL connection, const char *host, const char *username, const char *password, const char *database_name, unsigned int port, const char *unix_socket_name, unsigned int flags ) 3. Initialize Connection Handle Structure MYSQL *mysql_init(MYSQL *) 2. The database access routine more or less involves the following steps: 1. Let’s try out a database application using a very basic, low-level MySQL client C API library. Due to these reasons, the development of ODBC has slacked down in the recent years. This made native library more preferable over ODBC. And, in most cases, the underlying database layers have a direct link with the target database. ![]() Most Web development platforms work in layers with HTML as the intermediary between the user and the application. In recent years, due to the advent of thin client computing, the requirement of virtualization offered by ODBC has been reduced. It stands between the application and the database system to reciprocate the exchange of calls/responses among them. ODBC is basically a driver model that contains logic to convert a standard set of commands into calls understood by the underlying system. Most database vendors provide at least an ODBC driver apart from its native support. ODBC (Open Database Connectivity): Developed by Microsoft in the 90’s, it provides a vendor-neutral API to a access database system.While using the C++ connector, no C functions calls are required. There is a separate connector for C and as well as for C++. The API is based partially on the JDBC4.0 API standard and perhaps will be the standard way to access a database as it matures. MySQL C/C++ Connector: It is an innovation in its prime to make database connectivity simple and convenient.(Otherwise, it may be downloaded with the command, something like sudo apt-get install libmysqlclient libmysqlclient-dev in Ubuntu/Mint.) If you have MySQL Server installed, most probably the client API library is already installed. MySQL Client library: It is a native C API library distributed with MySQL and implemented in the libmysqlclient library.If you stick to one vendor-specific database, say MySQL, the driver options for database programming with C/C++ are: MySQL, for example, has its own client library and the API supplied by is are quite different from the API supplied by the client library of PostgreSQL. Client libraries are vendor specific that means that the API provided by one is different from another although the underlying principles are the same. Most database vendors provide a native client library to access a database. Except for ODBC its APIs are not standard. There are many practical ways to access a database in C/C++. Let’s get a first ride with the database code in C/C++ in this article. And the database programming? It’s quite fun, actually. But, once you overcome the preliminary hurdles, there is nothing like C/C++. This makes it more intriguing, challenging, that which tests your skills with every code you write. It is not easy to tread even a step superficially. C/C++, on the other hand, is a different breed. One of the interesting aspects of using a high-level language is that you can almost start coding with even a little understanding of the underlying principles. They are quite simple and convenient with an all-in-one-place library with very few configuration troubles. Modern high-level languages are pretty straightforward in these matters. ![]() If you think you need to sharpen those C/C#/C++ skills, visit the TechRepublic Academy today. Although the actually code is quite simple, it is the configuration issues such as importing right library, drivers to use, how to access them, and so forth, that make it an uphill battle. Creating a database application in C/C++ is a daunting task, especially for a novice programmer.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |