time. The application needs precompile, bind, and compile before execution. In
contrast, dynamic SQL statements can be built and executed at runtime. For
further details on embedded SQL. For more information refer to
IBM DB2 UDB
Application Development Guide: Building and Running Applications V8,
SC09 4825.
Another interface provided by DB2 UDB is DB2 Call Level Interface (CLI). It is a
standard based API following the Microsoft's Open Database Connectivity
(ODBC) specification and the ISO SQL/CLI standard. Both embedded SQL and
DB2 CLI support database administration as well as database manipulation from
C/C++ applications.
MySQL provides a client library for accessing a MySQL database from C
applications. MySQL C is included in the
mysqlclient
library. It provides features
for:
Connection mechanism
Creation and execution of SQL queries
Status and error reporting
MySQL Connector/C++(or MySQL ++) is an additional library for accessing
MySQL databases from C++ applications. It is another layer of abstraction on top
of the mysqlclient library.
Converting applications
MySQL C API and DB2 CLI are quite similar in functionality and mechanisms to
access databases. Both use the function call to pass dynamic SQL statements
and do not need to precompile. We recommend that you convert MySQL C
applications to DB2 CLI. This section describes conversion changes for various
levels of the application:
Connecting to the server
The first step in converting MySQL C applications is to change the include
information, initialize variables, and to replace the MySQL connection with a
DB2 connection. Example 7 45 shows a typical MySQL C program to initiate
MySQL variables, create a connection, and terminate the connection.
Example 7 45 MySQL C application, initialize MySQL and create connection
#include /* Include MySQL variable and function definition
*/
MYSQL *connection; /* pointer to connection handler */
int main()
{
if(mysql_init(MYSQL *mysql)==NULL) /* initiate the mysql variable */
{
/* handle error */
200
MySQL to DB2 UDB Conversion Guide
footer
Our partners:
PHP: Hypertext Preprocessor Cheap Web Hosting
JSP Web Hosting
Ontario Web Hosting
Jsp Web Hosting
Cheapest Web Hosting
Java Hosting
Cheapest Hosting
Visionwebhosting.net Business web hosting division of Vision Web Hosting Inc.. All rights reserved