深入数据库通用的连接方式详解_MySQL
bitsCN.com
每个数据的访问都用自己的通信协议,包括还有不同的接口调用,参数传递。在同一个程序里要使用不同数据库里的信息,按照正常的情况来说,那就要写不同的数据库连接的方法,就像在程序里写了多个精简版的 数据库 客户端。这样的编程方式肯定会让人不好难受,所以就期望能够有一种统一的访问数据库的方式,大家都用这一种方式去连接数据库,那么将减少很多痛苦。
话说微软是第一个给大家带来曙光的人,推出了ODBC的概念,从此所有的程序都不用自己写数据库连接程序了,从此跨入了解放时代。ODBC是一组基于C语言的API,它能兼容不同的数据库,然后提供统一的访问接口,这样就为大家节省出了YY的时间。
在ODBC推出后多年,有出了一个新概念OLE DB。这个是ODBC的升级版,因为一切都开始面向对象了,所以这个自然就是以对象方式来实现的。而且在性能方面也有了一些提高,自此OLE DB成为微软的新宠。
ODBC、OLE DB都是底层的数据库访问接口,使用起来不是很方便、容易,大家YY的时间又被占用的,为此微软决定再次解放大家、所以就出来了ADO的概念。很显然这是一个对象,就是对OLE DB、ODBC的高层封装,把大家经常要做的数据库操作都给直接提供出来,大家的YY时间再次被解救回来了。
不过在这期间Sun公司也没闲着,为了更大层次的解救JAVA程序猿们的YY时间,就单独写了一套专门用于JAVA的数据库访问接口JDBC,听名字就知道是山寨创意了。换汤不换药,唯一的好处就是java代码里调用会更舒服,自己家养的东西肯定用起来更顺手。
当然sun除了山寨创意外,还保留了对ODBC的调用接口【JDBC-ODBC桥】,以防不时之需;这样万一有一天除了一个新的东西只有ODBC支持,JDBC不支持。这时还不至于太有压力。当然ODBC的支持也是目前最广的,某些非主流的数据库文件的访问接口也都支持,所以还是留一手的好。
这样的话,数据库访问方式就开始明朗了。见下:
这样看来,用途最广、最底层的就是ODBC了。基本所有其它的都会可能调用它,JDBC、OLE DB是一个等级的;一个是sun的,一个是微软的;ADO不是直接访问的程序,只是一个访问快速通道而已。
注:所有的链接方式都需要本机有相应的驱动,而驱动是和具体的数据库是对应的。这样就会有3类驱动类型,每类访问N种数据库都要N个驱动。

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics
![VMware Horizon Client cannot be opened [Fix]](https://img.php.cn/upload/article/000/887/227/170835607042441.jpg?x-oss-process=image/resize,m_fill,h_207,w_330)
VMware Horizon Client helps you access virtual desktops conveniently. However, sometimes the virtual desktop infrastructure may experience startup issues. This article discusses the solutions you can take when the VMware Horizon client fails to start successfully. Why won't my VMware Horizon client open? When configuring VDI, if the VMWareHorizon client is not open, an error may occur. Please confirm that your IT administrator has provided the correct URL and credentials. If everything is fine, follow the solutions mentioned in this guide to resolve the issue. Fix VMWareHorizon Client Not Opening If VMW is not opening on your Windows computer
![VMware Horizon client freezes or stalls while connecting [Fix]](https://img.php.cn/upload/article/000/887/227/170942987315391.jpg?x-oss-process=image/resize,m_fill,h_207,w_330)
When connecting to a VDI using the VMWareHorizon client, we may encounter situations where the application freezes during authentication or the connection blocks. This article will explore this issue and provide ways to resolve this situation. When the VMWareHorizon client experiences freezing or connection issues, there are a few things you can do to resolve the issue. Fix VMWareHorizon client freezes or gets stuck while connecting If VMWareHorizon client freezes or fails to connect on Windows 11/10, do the below mentioned solutions: Check network connection Restart Horizon client Check Horizon server status Clear client cache Fix Ho

How to use PHP database connection to implement paging query. When developing web applications, it often involves the need to query the database and perform paging display. As a commonly used server-side scripting language, PHP has powerful database connection functions and can easily implement paging queries. This article will introduce in detail how to use PHP database connection to implement paging query, and attach corresponding code examples. Prepare the database Before we start, we need to prepare a database containing the data to be queried. Here we take the MySQL database as an example,

MQTT (MessageQueuingTelemetryTransport) is a lightweight message transmission protocol commonly used for communication between IoT devices. PHP is a commonly used server-side programming language that can be used to develop MQTT clients. This article will introduce how to use PHP to develop an MQTT client and include the following content: Basic concepts of the MQTT protocol Selection and usage examples of the PHPMQTT client library: Using the PHPMQTT client to publish and

When many friends download files, they will first browse on the web page and then transfer to the client to download. But sometimes users will encounter the problem that the Baidu Netdisk webpage cannot start the client. In response to this problem, the editor has prepared a solution for you to solve the problem that the Baidu Netdisk webpage cannot start the client. Friends in need can refer to it. Solution: 1. Maybe Baidu Netdisk is not the latest version. Manually open the Baidu Netdisk client, click the settings button in the upper right corner, and then click version upgrade. If there is no update, the following prompt will appear. If there is an update, please follow the prompts to update. 2. The detection service program of Baidu Cloud Disk may be disabled. It is possible that we manually or use security software to automatically disable the detection service program of Baidu Cloud Disk. Please check it out

Reasons for a PHP database connection failure include: the database server is not running, incorrect hostname or port, incorrect database credentials, or lack of appropriate permissions. Solutions include: starting the server, checking the hostname and port, verifying credentials, modifying permissions, and adjusting firewall settings.

How to configure database connection in mybatis: 1. Specify the data source; 2. Configure the transaction manager; 3. Configure the type processor and mapper; 4. Use environment elements; 5. Configure aliases. Detailed introduction: 1. Specify the data source. In the "mybatis-config.xml" file, you need to configure the data source. The data source is an interface, which provides a database connection; 2. Configure the transaction manager to ensure the normality of database transactions. For processing, you also need to configure the transaction manager; 3. Configure the type processor and mapper, etc.

Advanced PHP database connections involve transactions, locks, and concurrency control to ensure data integrity and avoid errors. A transaction is an atomic unit of a set of operations, managed through the beginTransaction(), commit(), and rollback() methods. Locks prevent simultaneous access to data via PDO::LOCK_SHARED and PDO::LOCK_EXCLUSIVE. Concurrency control coordinates access to multiple transactions through MySQL isolation levels (read uncommitted, read committed, repeatable read, serialized). In practical applications, transactions, locks and concurrency control are used for product inventory management on shopping websites to ensure data integrity and avoid inventory problems.
