JDBC is a platform-independent interface between relational databases and Java. In today’s Java world, JDBC is a standard application programming interface(API) for accessing enterprise data in relational
databases using Structured Query Language(SQL).
JDBC is a set of programming APIs that allows easy connection to a wide range of databases(especially relational databases) through Java programs.
The JDBC API is defined by two packages:
Java.sql provides the API for accessing and processing data stored in a data source(usually a relational database)using the Java programming language. This package provides the foundation and most commonly
used objects(such as Connection, ResultSet, Statement, and PreparedStatement).
Javax.sql provides the API for server-side data source access and processing from the Java programming language. According to the JDK documentation, “this package supplements the java.sql package and, as
of the version 1.4 release, is included in the JDK. It remains an essential part of [I2EE].”
More specifically, JDBC is a low-level , simple(has a well-defined API), and portable(since Java is portable across platforms) SQL call-level interface(CLI) written in Java.
JDBC’s detail architecture
The JDBC API does most of the things through the DriverManager class(java.sql.DriverManager). What is DriverManager? It is a connection factory class. In fact, DriverManager is the only class that can create
database connections. (Each database connection is represented by an instance of a java.sql.Connection.) The DriverManager uses drivers to create connections. Each vendor(such as Oracle,MySQL, and Sybase) provides a set of drivers.
Java Application using JDBC components
Who provides these JDBC drivers? Usually, a database vendor(such as MySQL,Oracle,Sybase,and so on) writes a JDBC driver(a specific software for a specific database), which is a set of classes/interfaces that
implements these interfaces(such as java.sql.Driver) for a particular database system. Following the JDBC architecture, a Java database application uses the DriverManager class to get the java.sql.Connection object, which represents a database connection.
Then, using a Connection object, you can create Statement/PreparedStatement/CallableStatement, which can execute SQL queries and stored procedures and return results as ResultSert objects. (ResultSet is a table of data representing a database result set,
which is usually generated by executing a statement that queries the database.)
The following are core JDBC classes, interfaces, and exceptions in the java.sql package:
DriverManager: This class loads JDBC drivers in memory. You can also use it to create java.sql.Connection objects to data sources.
Connection: This interface represents a connection with a data source. You can use the Connection object for creating Statement, PreparedStatement, and CallableStatement objects.
Statement: This interface represents a static SQL statement. You can use it to retrieve ResultSet objects.
PreparedStatement: This interface extends Statement and represents a precompiled SQL statement. You can use it to retrieve ResultSet objects.
CallableStatement: This interface represents a database stored procedure. You can use it to execute stored procedures in a database server.
ResultSet: This interface represents a database result set generated by using SQL’s SELECT statement.
SQLException: This class is an exception class that provides information on a database access error or other errors.
分享到:
相关推荐
SUN网站上找的英文版JAVA教程,Java Tutorial,只要你英文过四级,这绝对是JAVA SE最棒的学习资料.内容基本含概了JAVA SE的所有方面,从基本语法,继承,Generic,IO,序列化,到JavaBean,Swing组件,XML,正则表达式,JDBC,JAVA...
SUN网站上找的英文版JAVA教程,Java Tutorial,只要你英文过四级,这绝对是JAVA SE最棒的学习资料.内容基本含概了JAVA SE的所有方面,从基本语法,继承,Generic,IO,序列化,到JavaBean,Swing组件,XML,正则表达式,JDBC,JAVA...
SUN网站上找的英文版JAVA教程,Java Tutorial,只要你英文过四级,这绝对是JAVA SE最棒的学习资料.内容基本含概了JAVA SE的所有方面,从基本语法,继承,Generic,IO,序列化,到JavaBean,Swing组件,XML,正则表达式,JDBC,JAVA...
SUN网站上找的英文版JAVA教程,Java Tutorial,只要你英文过四级,这绝对是JAVA SE最棒的学习资料.内容基本含概了JAVA SE的所有方面,从基本语法,继承,Generic,IO,序列化,到JavaBean,Swing组件,XML,正则表达式,JDBC,JAVA...
甲骨文Java官方教程,涉及Java的各个方面,数据结构,并发,IO,网络,环境,反射,泛型,图形界面,JDBC,JAXB等,层次清晰,案例鲜明。可以在Oracle官网浏览,本资源提供CHM格式便于查阅。
jdbc-introduce.pdf Oracle_JDBC_tutorial.pdf 基于JDBC并利用属性文件来配置和实现数据库连接池.pdf 数据库连接池Java实现小结.doc
tutorial_JDBC 初学者使用MySql的Java JDBC教程
Before proceeding with this tutorial, you should have a good knowledge of the Java programming language. A good way to get to that point is to work through The Java Tutorial, Fourth Edition, Sharon ...
SUN网站上找的英文版JAVA教程,Java Tutorial,只要你英文过四级,这绝对是JAVA SE最棒的学习资料.内容基本含概了JAVA SE的所有方面,从基本语法,继承,Generic,IO,序列化,到JavaBean,Swing组件,XML,正则表达式,JDBC,JAVA...
☆ Java Naming and Directory Interface (JNDI,Java名字与目录接口) ☆ XML ☆ J2EE Connector Architecture (J2EE连接器架构) ☆ JavaMail ☆ JDBC <br>当你...
JDBC API知道和开发引用
JDBC API教程与参考手册(第三版)PDF格式。 这是我从收费网站上扒下来的。嘿嘿 先放出前言+目录+第一,二章,大家如果有兴趣我会把后面的一起放出来的。这本书现在好像没得卖了哟。嘿嘿。
MySQL provides connectivity for client applications developed in the Java programming language via a JDBC driver, which is called MySQL Connector/J. MySQL Connector/J is a JDBC-3.0 Type 4 driver, ...
源代码指导Java的基本知识,例如:安装Java开发环境,创建和运行Java程序,声明变量,数据类型,使用数组,控件结构,编码标准(编码约定),数据类型转换,枚举,正则表达式, ... 链接: : Java中的面向对象...
☆ Java Naming and Directory Interface (JNDI,Java名字与目录接口) ☆ XML ☆ J2EE Connector Architecture (J2EE连接器架构) ☆ JavaMail ☆ JDBC <br>当你...
☆ Java Naming and Directory Interface (JNDI,Java名字与目录接口) ☆ XML ☆ J2EE Connector Architecture (J2EE连接器架构) ☆ JavaMail ☆ JDBC <br> 当你准备创建自己的大型...
/*你可以访问这个连接获得getxxx的用法:http://java.sun.com/docs/books/tutorial/jdbc/basics/_retrievingTable.html*/ } stmt.close(); con.close(); //上面的语句关闭声明和连接 } catch(SQLException ex) ...
It also serves as a useful reference and self-study tutorial to Java programming. The Deitels’ groundbreaking How to Program series offers unparalleled breadth and depth of object-oriented ...