一、示例分析CreateTable,Insert,Update,Delete,Select,DropTable:
1〉java.sql中主要的类和接口:DriverManager,Connection,Statement,ResultSet;
2〉在中如何加载驱动程序,如何建立数据库连接,如何执行SQL语句,如何处理峁???
二、基础概念1、JDBC框架
JDBC( DataBase Connectivity)是Java与数据库的接口规范,由Java 语言编写的类和接口组成,大致分为两类:针对Java
程序员的JDBC API和针对数据库开发商的低层的JDBC driver API。而JDBC驱动程序由实施了这些接口的类组成。如下,
JDBC的总体结构有四个组件:应用程序、驱动程序管理器、驱动程序和数据源。
2、驱动程序类型
JDBC驱动器根据其实现方式分为4种类型
1、JDBC-ODBC bridge plus ODBC driver: JDBC-ODBC桥驱动程序,将JDBC调用转换为ODBC的调用。( This combination provides JDBC access via ODBC drivers. ODBC binary code--and in many cases, database client code-- must be loaded on each client machine that uses a JDBC-ODBC Bridge. Sun provides a JDBC-ODBC Bridge driver, which is appropriate for experimental use and for situations in which no other driver is available.)
2、Native-API partly-Java driver: 将JDBC调用转换为对数据库客户端API的调用。(A native-API partly Java technology-enabled driver: This type of driver converts JDBC calls into calls on the client API for , Sybase, Informix, DB2, or other DBMS. Note that, like the bridge driver, this style of driver requires that some binary code be loaded on each client machine.)
3、 Pure Java Driver for Database Middleware: 先将JDBC调用转换为DBMS-independent网络,然后由端的中间件转换为具体数据库可以接收的网络。(net-protocol fully Java technology-enabled driver #This style of driver translates JDBC calls into the middleware vendor's protocol, which is then translated to a DBMS protocol by a middleware server. The middleware provides connectivity to many different databases.)
4、Direct-to-Database Pure Java Driver: 将JDBC调用直接转换为具体数据库服务器可以接收的网络。(native-protocol fully Java technology-enabled driver #This style of driver converts JDBC calls into the network protocol used directly by DBMSs, allowing a direct call from the client machine to the DBMS server and providing a practical solution for intranet access.)
【责编:Star】
--------------------next---------------------