Realization and application of VC in MySQL database interface

Source: Internet
Author: User
Tags odbc mysql in php and mysql database

Absrtact: MySQL database as a network database performance is very good, but it is less used in application software. This article will discuss the two database interfaces provided by MySQL--(ODBC API and C API) in VC application, and form a class to encapsulate the C API database interface function.

Introduction

With the development of modern computer hardware and software and network technology, it has become one of the most important means to find information on the Internet. As we all know, all the online information is stored in the Web site database, the information of the query, update and other functions are provided by the database server, obviously, the performance of the database server will be directly related to the survival of the site. The most database server used in the site is Oracle and MySQL, the former is powerful, the flagship database server, but the upfront investment is too large, the latter function is constantly improved, simple and easy to use without losing performance, and can be obtained free of charge. Therefore, many small and medium-sized Web site database server to choose MySQL, and, because of MySQL performance, some large web site also selected MySQL.

This shows that the MySQL database server in the construction of the site is very good performance. However, because of this, very few people use MySQL in the development of application software. This article will detail the VC environment MySQL database server different interface application, and eventually will produce a CDatabase class encapsulation MySQL database interface function.

Database interface implementation and application of the computer environment: hardware, C466, 128M, 15G, software and operating system, VISUAL C + + 6.0, MySQL 3.23.22-beta for Win32, WIN98.

1 Introduction to MySQL Database

MySQL is a real multi-user, multi-threaded SQL database server. SQL (Structured Query language) is the most popular and standardized database language in the world, making it easier to store, update, and access information. MySQL is a client/server architecture implementation that consists of a server daemon mysqld and many different client programs and libraries.

The main goal of MySQL is to be fast, robust, and easy to use. Originally because the founder of MySQL needs such a SQL Server, it can handle with any inexpensive hardware platform to provide a database of the manufacturers in a large scale database, but faster, MySQL thus developed. It provides C,c++,java (JDBC), perl,python,php and TCL API interfaces, multi-platform support, including Solaris,sunos,bsdi,sgi Irix,aix,dec Unix,linux,freebsd, SCO Openserver,netbsd,openbsd,hpux,win9x and NT; a variety of data types, including/unsigned 1,2,3,4,8 bytes Integers,float,double,char,varchar,text , Blob,date,datetime,year,set,enum, very flexible and secure permissions system, password encryption, provide Windows ODBC interface, can be connected through access, and a third party developers to provide a variety of ODBC drivers The maximum table size of the new MyISAM in MySQL 3.23 can be up to 8 million TB (2^63 bytes), multiple language support, but not Chinese. However, in order to achieve fast, robust and easy to use, MySQL must sacrifice a part of flexible and powerful features, such as subqueries, stored procedures and triggers, foreign keys, things to deal with. As a result, MySQL lacks flexibility in some applications, but it also allows it to process data at least 2~3 times faster than other database servers.

MySQL itself does not support the graphical interface of Windows, so all database operations and management functions can only be done in MS-DOS mode. First, you must login to the MySQL server, that is, under the prompt \mysql\bin> input mysql–h host–u User–ppassword, the prompt to mysql> when the landing success. Then, select the database that you are working with, that is, mysql> use DatabaseName. You can then query with an SQL statement. If you need to exit the database server, you can execute the QUIT command, which will successfully exit the server. Of course, due to the increasing popularity of MySQL, many third-party software companies have introduced MySQL in the Windows environment with graphical interface support software, such as EMS Company's EMS MySQL Manager to provide windows in the form of MySQL database operating functions.

2 using ODBC API to realize MySQL database function call

ODBC (Open Database Connectivity), an open databases interconnect, is already familiar to many Windows programmers as an important part of Windows open architecture, and the work of ODBC relies on the drivers provided by the database manufacturer. When using the ODBC API, Windows ODBC Administrator passes requests for database access to the correct driver, and the driver uses SQL statements to instruct the DBMS (database management System) to complete the database access work, so The presence of ODBC provides us with a very strong ability and flexibility to develop application database programs. You can install an ODBC database on a variety of databases under Windows to connect to the database and access their data.

For the MySQL database server, its manufacturer also provides the appropriate ODBC driver, the latest version of which is Myodbc-2.50.31-win95. After installation in a WIN98 environment, you can use the programming language to perform various ODBC-supported operations on the MySQL database through the ODBC API. Because ODBC masks differences in various databases, programs that are used to manipulate other databases can also operate on MySQL databases through ODBC. In other words, ODBC makes the program more versatile to the database.

VC through the ODBC API to the MySQL database programming, you must have to set the MySQL data source, specific settings such as Figure 1:

Figure 1 Data source setup Information

By setting up the diagram above, we can program the MySQL database according to the common ODBC database programming method.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.