Content deleted Content added
→Functionality: Fix sfn issues. |
|||
(14 intermediate revisions by 12 users not shown) | |||
Line 1:
{{Short description|API for Java}}
'''Java Database Connectivity''' ('''JDBC''') is an [[application programming interface]] (API) for the [[Java (programming language)|Java]] programming language which defines how a client may access a [[database]]. It is a Java-based data access technology used for Java database connectivity. It is part of the [[Java Standard Edition]] platform, from [[Oracle Corporation]]. It provides methods to query and update data in a database, and is oriented toward [[
|name = JDBC
|logo =
Line 14:
|website = {{Javadoc:SE-guide|jdbc|JDBC API Guide}}
}}
▲'''Java Database Connectivity''' ('''JDBC''') is an [[application programming interface]] (API) for the [[Java (programming language)|Java]] programming language which defines how a client may access a [[database]]. It is a Java-based data access technology used for Java database connectivity. It is part of the [[Java Standard Edition]] platform, from [[Oracle Corporation]]. It provides methods to query and update data in a database, and is oriented toward [[relational database]]s. A JDBC-to-[[ODBC]] bridge enables connections to any ODBC-accessible data source in the [[Java virtual machine]] (JVM) host environment.
==History and implementation==
[[Sun Microsystems]] released JDBC as part of [[Java Development Kit]] (JDK) 1.1 on February 19, 1997.<ref name="JDK 1.1 release">
{{cite web
| title = Sun Ships JDK 1.1 -- Javabeans Included
Line 34 ⟶ 32:
Since then it has been part of the [[Java Platform, Standard Edition]] (Java SE).
The JDBC classes are contained in the [[Java package]] {{Javadoc:SE|package=java.sql|java/sql|module=java.sql}} and {{Javadoc:SE|package=javax.sql|javax/sql|module=java.sql}}, as well as a few other classes elsewhere. Everything involved in JDBC is exported through [[Java Platform Module System|module]] <code>java.sql</code>.
Starting with version 3.1, JDBC has been developed under the [[Java Community Process]]. JSR 54 specifies JDBC 3.0 (included in J2SE 1.4), JSR 114 specifies the JDBC Rowset additions, and JSR 221 is the specification of JDBC 4.0 (included in Java SE 6).<ref>[http://java.sun.com/products/jdbc/download.html#corespec40 JDBC API Specification Version: 4.0].</ref>
Line 43 ⟶ 41:
The latest version, JDBC 4.3, is specified by a maintenance release 3 of JSR 221<ref>{{cite web|url=https://jcp.org/aboutJava/communityprocess/mrel/jsr221/index3.html|title=The Java Community Process(SM) Program - communityprocess - mrel|website=jcp.org|access-date=22 March 2018}}</ref> and is included in Java SE 9.<ref>{{cite web|url=http://docs.oracle.com/javase/9/docs/api/java/sql/package-summary.html|title=java.sql (Java SE 9 & JDK 9)|website=docs.oracle.com|access-date=22 March 2018}}</ref>
{| class="wikitable"
|+ JDBC versions
|-
! JDBC version !! Java version !! Release Type !! Release date
|-
| 1.1 || JDK 1.1 || Main || 1997-02-19.<ref name="JDK 1.1 release" />
|-
| [https://www.jcp.org/en/jsr/detail?id=54 3.0] || J2SE 1.4 || Main || 2002-05-09
|-
| [https://www.jcp.org/en/jsr/detail?id=221 4.0] || Java SE 6 || Main || 2006-12-11
|-
| [https://www.jcp.org/en/jsr/detail?id=221 4.1] || Java SE 7 || Maintenance || 2011-10-13
|-
| [https://www.jcp.org/en/jsr/detail?id=221 4.2] || Java SE 8 || Maintenance || 2014-03-04
|-
| [https://www.jcp.org/en/jsr/detail?id=221 4.3] || Java SE 9 || Maintenance || 2017-09-21
|}
==Functionality==
Line 100 ⟶ 116:
|}
Since JDBC
JDBC connections support creating and executing statements. JDBC connections support update statements such as SQL's [[Create (SQL)|CREATE]], [[Insert (SQL)|INSERT]], [[Update (SQL)|UPDATE]] and [[Delete (SQL)|DELETE]], or query statements such as [[Select (SQL)|SELECT]]. Additionally, stored procedures may be invoked through a JDBC connection. JDBC represents statements using one of the following classes:
Line 106 ⟶ 122:
* {{Javadoc:SE|java/sql|PreparedStatement|module=java.sql}} – {{code|PreparedStatement}} is a subinterface of the {{code|Statement}} interface.{{sfn | Bai | 2022 | p=74}} The statement is cached and then the [[Query plan|execution path]] is pre-determined on the database server, allowing it to be executed multiple times in an efficient manner.{{sfn | Bai | 2022 | p=74}} {{code|PreparedStatement}} is used to execute pre-compiled SQL statements.{{sfn | Bai | 2022 | p=74}} Running pre-compiled statements increases statement execution efficiency and performance. The {{code|PreparedStatement}} is often used for dynamic statement where some input parameters must be passed into the target database.{{sfn | Bai | 2022 | loc=§4.2.3.5 More About the Execution Methods | pp=122-124}} The
{{code|PreparedStatement}} allows the dynamic query to vary depending on the query parameter.{{sfn | Bai | 2022 | loc= §3.2 JDBC Components and Architecture | pp=72-74}}
* {{Javadoc:SE|java/sql|CallableStatement|module=java.sql}} – {{code|CallableStatement}} is a subinterface of the {{code|Statement}} interface.{{sfn | Bai | 2022 | loc= §3.2 JDBC Components and Architecture | pp=72-74}} It is used for executing [[stored procedures]] on the database.{{sfn | Bai | 2022 | loc= §3.2 JDBC Components and Architecture | pp=72-74}}{{sfn | Horstmann | 2022 | loc=§5.5.3 SQL Escapes}} Both input and
Update statements such as INSERT, UPDATE and DELETE return an update count indicating the number of [[Row (database)|rows]] affected in the database as an integer.{{sfn | Bai | 2022 | loc= §4.2.3.5 JDBC Components and Architecture | pp=122-124}} These statements do not return any other information.
Line 112 ⟶ 128:
Query statements return a JDBC row result set. The row result set is used to walk over the [[result set]]. Individual [[Column (database)|columns]] in a row are retrieved either by name or by column number. There may be any number of rows in the result set. The row result set has metadata that describes the names of the columns and their types.
There is an extension to the basic JDBC API in the {{Javadoc
JDBC connections are often managed via a [[connection pool]] rather than obtained directly from the driver.{{sfn | Bai | 2022 | loc=§3.5.1 JDBC DataSource | p=83}}
==Examples==
Line 294 ⟶ 310:
}}
</ref>
supplied with [[Oracle Database
===Sources===
Line 300 ⟶ 316:
* [[Simba Technologies]] ships an SDK for building custom JDBC Drivers for any custom/proprietary relational data source
* CData Software ships type 4 JDBC Drivers for various applications, databases, and Web APIs.<ref>{{cite web|url=http://www.cdata.com/jdbc/|title=JDBC Drivers - CData Software|website=CData Software|access-date=22 March 2018}}</ref>
* RSSBus Type 4 JDBC Drivers for applications, databases, and web services<ref>{{cite web|url=http://www.rssbus.com/jdbc/|title=JDBC Drivers - CData Software|website=CData Software|access-date=22 March 2018|archive-date=22 December 2015|archive-url=https://web.archive.org/web/20151222115409/http://www.rssbus.com/jdbc/|url-status=dead}}</ref>
* DataDirect Technologies provides a comprehensive suite of fast Type 4 JDBC drivers for all major database they advertise as Type 5<ref name=datadirect>{{cite web
| url=http://www.datadirect.com/products/features/data-connectivity/type-5-jdbc/index.html
Line 328 ⟶ 344:
== References ==
* {{cite book | last=Bai | first=Ying | title=SQL Server Database Programming with Java | publisher=[[Springer International Publishing]] | publication-place=Cham | year=2022 | isbn=978-3-030-92686-1 | doi=10.1007/978-3-031-06553-8}}
* {{cite book | last=Horstmann | first=Cay | title=Core Java | publisher=Oracle Press Java | date=April 15, 2022 | isbn=978-0-13-787107-
==External links==
Line 341 ⟶ 357:
{{DEFAULTSORT:Database Connectivity}}
[[Category:
[[Category:Java specification requests]]
[[Category:SQL data access]]
[[Category:Database APIs]]
|