Qdb commands quick reference . GDB is used to debug C/C++ program on unix.
Below are the quick command of C/C++
Starting GDB
gdb start GDB, with no debugging _les
gdb program begin debugging program
gdb program core debug coredump core produced by program
gdb --help describe command line options
More Help on gdb on starting , stoping setting breakpoint in gdb
Saturday, March 20, 2010
How to access Oracle from C++ on Linux ?
It is
Oracle C++ Call Interface
Oracle C++ Call Interface (OCCI) is a high-performance and comprehensive API to access the Oracle database. Based on Standard C++ and object-oriented paradigm, OCCI is designed for improved productivity and quality in developing Oracle database applications.
Introduced in Oracle9i, OCCI is being successfully used for client-server, middle-tier, and complex object modeling applications.
The Instant Client feature makes it extremely easy and fast to deploy an OCCI based application by eliminating the need and disk space of a full Oracle Client install. Users just need to install a small sized archive containing all the Oracle dynamic libraries to run their OCCI applications.
What's new in OCCI in Oracle 11g R1 release :
* Database Resident Connection Pooling(DRCP)
* SecureFile LOBs, Compression, Encryption, and Deduplication
* Client ResultSet cache
* Runtime Connection Load balancing
* Fault Diagnosability
* Objects access performance improvements
Oracle C++ Call Interface
Oracle C++ Call Interface (OCCI) is a high-performance and comprehensive API to access the Oracle database. Based on Standard C++ and object-oriented paradigm, OCCI is designed for improved productivity and quality in developing Oracle database applications.
Introduced in Oracle9i, OCCI is being successfully used for client-server, middle-tier, and complex object modeling applications.
The Instant Client feature makes it extremely easy and fast to deploy an OCCI based application by eliminating the need and disk space of a full Oracle Client install. Users just need to install a small sized archive containing all the Oracle dynamic libraries to run their OCCI applications.
What's new in OCCI in Oracle 11g R1 release :
* Database Resident Connection Pooling(DRCP)
* SecureFile LOBs, Compression, Encryption, and Deduplication
* Client ResultSet cache
* Runtime Connection Load balancing
* Fault Diagnosability
* Objects access performance improvements
Connecting MySQL with C++ on Linux
MySQL API ..
The C API code to connect mysql on unix ( linux ) is being distributed with MySQL. It is the part of mysqlclient library and allows C programs to access a database.
Following packages needs to be compiled to access mysql from C/C++ on unix.
* mysql: MySQL client programs and shared library
* mysqlclient: Backlevel MySQL shared libraries (old libs)
* mysql-devel: Files for development of MySQL applications (a must have)
* mysql-server: Mysql server itself
* gcc, make and other development libs: GNU C compiler
How do I compile and link program against MySQL libs?
$ mysql_config --libs
$ mysql_config --cflags
$ gcc -o output-file $(mysql_config --cflags) mysql-c-api.c $(mysql_config --libs)
$ ./output-file
Sample Program
/* Simple C program that connects to MySQL Database server*/
#include
#include
main() {
MYSQL *conn;
MYSQL_RES *res;
MYSQL_ROW row;
char *server = "localhost";
char *user = "root";
char *password = "PASSWORD"; /* set me first */
char *database = "mysql";
conn = mysql_init(NULL);
/* Connect to database */
if (!mysql_real_connect(conn, server,
user, password, database, 0, NULL, 0)) {
fprintf(stderr, "%s\n", mysql_error(conn));
exit(1);
}
/* send SQL query */
if (mysql_query(conn, "show tables")) {
fprintf(stderr, "%s\n", mysql_error(conn));
exit(1);
}
res = mysql_use_result(conn);
/* output table name */
printf("MySQL Tables in mysql database:\n");
while ((row = mysql_fetch_row(res)) != NULL)
printf("%s \n", row[0]);
/* close connection */
mysql_free_result(res);
mysql_close(conn);
}
The C API code to connect mysql on unix ( linux ) is being distributed with MySQL. It is the part of mysqlclient library and allows C programs to access a database.
Following packages needs to be compiled to access mysql from C/C++ on unix.
* mysql: MySQL client programs and shared library
* mysqlclient: Backlevel MySQL shared libraries (old libs)
* mysql-devel: Files for development of MySQL applications (a must have)
* mysql-server: Mysql server itself
* gcc, make and other development libs: GNU C compiler
How do I compile and link program against MySQL libs?
$ mysql_config --libs
$ mysql_config --cflags
$ gcc -o output-file $(mysql_config --cflags) mysql-c-api.c $(mysql_config --libs)
$ ./output-file
Sample Program
/* Simple C program that connects to MySQL Database server*/
#include
#include
main() {
MYSQL *conn;
MYSQL_RES *res;
MYSQL_ROW row;
char *server = "localhost";
char *user = "root";
char *password = "PASSWORD"; /* set me first */
char *database = "mysql";
conn = mysql_init(NULL);
/* Connect to database */
if (!mysql_real_connect(conn, server,
user, password, database, 0, NULL, 0)) {
fprintf(stderr, "%s\n", mysql_error(conn));
exit(1);
}
/* send SQL query */
if (mysql_query(conn, "show tables")) {
fprintf(stderr, "%s\n", mysql_error(conn));
exit(1);
}
res = mysql_use_result(conn);
/* output table name */
printf("MySQL Tables in mysql database:\n");
while ((row = mysql_fetch_row(res)) != NULL)
printf("%s \n", row[0]);
/* close connection */
mysql_free_result(res);
mysql_close(conn);
}
Subscribe to:
Posts (Atom)