JDBC(TM) Database Access: Table of Contents
1.JDBC Introduction
The JDBC API is a Java API that can access any kind of tabular data, especially data stored in a Relational Database.
(“任何表单数据,特别是关系型数据”他想说明什么?它也支持非关系型数据库咯)
JDBC helps you to write java applications that manage these three programming activities:
(3步,连接数据源,发送查询或修改请求,获取并处理请求结果。谁谁谁说有6大步,今天又看到3个步骤。嘿嘿)
Connect to a data source, like a database
Send queries and update statements to the database
Retrieve and process the results received from the database in answer to your query
The following simple code fragment gives a simple example of these three steps:
Connection con = DriverManager.getConnection
( "jdbc:myDriver:wombat", "myLogin","myPassword");
Statement stmt = con.createStatement();
ResultSet rs = stmt.executeQuery("SELECT a, b, c FROM Table1");
while (rs.next()) {
int x = rs.getInt("a");
String s = rs.getString("b");
float f = rs.getFloat("c");
}
This short code fragment instantiates a DriverManager object to connect to a database driver and log into the database, instantiates a Statement object that carries your SQL language query to the database; instantiates a ResultSet object that retrieves the results of your query, and executes a simple while loop, which retrieves and displays those results. It's that simple.
(他的tutorial居然先给人看一段代码,然后说It's that simple。不知道对于刚开始接触jdbc的人来说,这段代码是不是如他所说的that simple了)
2.JDBC Product Components
JDBC includes four components:
(4个组成部分)
The JDBC API —
(JDBC API分在2个包内java.sql和javax.sql。都包含在SE和EE的版本内。主要用于编程。)
The JDBC™ API provides programmatic access to relational data from the Java™ programming language. Using the JDBC API, applications can execute SQL statements, retrieve results, and propagate changes back to an underlying data source. The JDBC API can also interact with multiple data sources in a distributed, heterogeneous environment.
The JDBC API is part of the Java platform, which includes the Java™ Standard Edition (Java™ SE ) and the Java™ Enterprise Edition (Java™ EE). The JDBC 4.0 API is divided into two packages: java.sql and javax.sql. Both packages are included in the Java SE and Java EE platforms.
JDBC Driver Manager —
(驱动管理和扩展包里的DataSource.DriverManager是核心)
The JDBC DriverManager class defines objects which can connect Java applications to a JDBC driver. DriverManager has traditionally been the backbone of the JDBC architecture. It is quite small and simple.
The Standard Extension packages javax.naming and javax.sql let you use a DataSource object registered with a Java Naming and Directory Interface™ (JNDI) naming service to establish a connection with a data source. You can use either connecting mechanism, but using a DataSource object is recommended whenever possible.
JDBC Test Suite —
(测试包)
The JDBC driver test suite helps you to determine that JDBC drivers will run your program. These tests are not comprehensive or exhaustive, but they do exercise many of the important features in the JDBC API.
JDBC-ODBC Bridge —
(桥)
The Java Software bridge provides JDBC access via ODBC drivers. Note that you need to load ODBC binary code onto each client machine that uses this driver. As a result, the ODBC driver is most appropriate on a corporate network where client installations are not a major problem, or for application server code written in Java in a three-tier architecture.
This Trail uses the first two of these these four JDBC components to connect to a database and then build a java program that uses SQL commands to communicate with a test Relational Database. The last two components are used in specialized environments to test web applications, or to communicate with ODBC-aware DBMSs.
3.JDBC Architecture
(JDBC还分什么两层架构,三层架构??跟他没关系咯)
The JDBC API supports both two-tier and three-tier processing models for database access.
In the two-tier model, a Java applet or application talks directly to the data source. This requires a JDBC driver that can communicate with the particular data source being accessed. A user's commands are delivered to the database or other data source, and the results of those statements are sent back to the user. The data source may be located on another machine to which the user is connected via a network. This is referred to as a client/server configuration, with the user's machine as the client, and the machine housing the data source as the server. The network can be an intranet, which, for example, connects employees within a corporation, or it can be the Internet.
In the three-tier model, commands are sent to a "middle tier" of services, which then sends the commands to the data source. The data source processes the commands and sends the results back to the middle tier, which then sends them to the user. MIS directors find the three-tier model very attractive because the middle tier makes it possible to maintain control over access and the kinds of updates that can be made to corporate data. Another advantage is that it simplifies the deployment of applications. Finally, in many cases, the three-tier architecture can provide performance advantages.
Until recently, the middle tier has often been written in languages such as C or C++, which offer fast performance. However, with the introduction of optimizing compilers that translate Java bytecode into efficient machine-specific code and technologies such as Enterprise JavaBeans™, the Java platform is fast becoming the standard platform for middle-tier development. This is a big plus, making it possible to take advantage of Java's robustness, multithreading, and security features.
(这段话有点像广告。是不是说EJB之前,java还不能跨入三层架构的行列?)
With enterprises increasingly using the Java programming language for writing server code, the JDBC API is being used more and more in the middle tier of a three-tier architecture. Some of the features that make JDBC a server technology are its support for connection pooling, distributed transactions, and disconnected rowsets. The JDBC API is also what allows access to a data source from a Java middle tier.
(支持连接池,分布式的事务和非连接的结果集。使JDBC看起来更像服务段技术。)
分享到:
- 2008-05-08 23:00
- 浏览 1257
- 评论(1)
- 论坛回复 / 浏览 (1 / 1929)
- 查看更多
相关推荐
jdbc api tutorial and reference Addison Wesley - JDBC API Tutorial and Reference, Third Edition
对jdbc api的详细介绍和指南,想要深入学习jdbc的最佳书籍
这是我为这些英文教材写的序言(不敢当) http://blog.csdn.net/luozhuang/archive/2007/06/05/1639551.aspx
JDBC™ API Tutorial and Reference, Third Edition By Maydene Fisher, Jon Ellis, Jonathan Bruce Publisher : Addison Wesley Pub Date : June 13, 2003 ISBN : 0-321-17384-8
MySQL provides connectivity for client ...• JDBC Basics — A tutorial from Sun covering beginner topics in JDBC • JDBC Short Course — A more in-depth tutorial from Sun and JGuru Key topics:
实在对不起大家,之前传的这个有问题。是我的疏忽,不是我有意骗大家分。我重新上传了。这个就不要再下了。 #非常棒的一本入门教程,配合java api doc 中文看,黄金搭档。
SUN Java certificate tutorial.rar
pdf files from IBM, good tutorial to learn Ajax, enjoy.
<br>《The J2EETM Tutorial 中文版》的作者是Sun Microsystem公司Java开发小组资深的开发人员,与另一部取得空前成功的《The JavaTM Tutorial》一样,建立了与读者之间最为有效的交互途径。同时,在本书的...
JDBC API教程与参考手册(第三版)PDF格式。 这是我从收费网站上扒下来的。嘿嘿 先放出前言+目录+第一,二章,大家如果有兴趣我会把后面的一起放出来的。这本书现在好像没得卖了哟。嘿嘿。
FMC-IMAGEON - Building a Video Design from Scratch Tutorial - 14.4 - 20130103.pdf
通过一个实例代码完全描述了决策树的构造过程。具有很好的学习和借鉴意义。(PDF文档)
JDBC API知道和开发引用
Java EE 6 tutorial.Sun官方的教程。JaveEE6可能会火,前途未知。
j3d_tutorial\ j3d教程sun官方版 j3d_tutorial\ j3d教程sun官方版
《The J2EETM Tutorial 中文版》的作者是Sun Microsystem公司Java开发小组资深的开发人员,与另一部取得空前成功的《The JavaTM Tutorial》一样,建立了与读者之间最为有效的交互途径。同时,在本书的编写过程中,也...
清华大学同方的一个网页方式的Java编程教程,有flash播放,同学们学习Java的一个不错的教程
Tutorial