Package java.sql

Source: Internet
Author: User
Tags connection pooling time zones savepoint java se

Provides the API for accessing and processing data stored in a data source (usually a relational database) using the Java? Programming language. This API includes a framework whereby different drivers can is installed dynamically to access different data sources. Although the JDBC? API is mainly geared to passing SQL statements to a database, it provides for reading and writing data from any data sourc E with a tabular format. The Reader/writer facility, available through the javax.sql.RowSet group of interfaces, can be customized-use and update data from A spread sheet, flat file, or any other tabular data source.

What is the JDBC? 4.3 API includes

The JDBC? 4.3 API includes both the package, referred to as the java.sql JDBC Core API, and javax.sql the package, referred to as the JDBC Optional Package API. This all JDBC API is included in the Java? Standard Edition (Java SE?), version 7. javax.sqlThe package extends the functionality of the JDBC API from a Client-side API to a Server-side API, and it's an esse Ntial part of the Java? Enterprise Edition (Java EE?) technology.

Versions

The JDBC 4.3 API incorporates all of the previous JDBC API versions:

    • The JDBC 4.2 API
    • The JDBC 4.1 API
    • The JDBC 4.0 API
    • The JDBC 3.0 API
    • The JDBC 2.1 core API
    • The JDBC 2.0 Optional package API
      (Note that the JDBC 2.1 core API and the JDBC 2.0 Optional package API together is referred to as the JDBC 2.0 API.)
    • The JDBC 1.2 API
    • The JDBC 1.0 API

Classes, interfaces, methods, fields, constructors, and exceptions had the following "since" tags that indicate when they were introduced into the Java platform. When these "since" tags is used in Javadoc? Comments for the JDBC API, they indicate the following:

    • Since 9--New in the JDBC 4.3 API and part of the Java SE platform, version 9
    • Since 1.8--New in the JDBC 4.2 API and part of the Java SE platform, version 8
    • Since 1.7--New in the JDBC 4.1 API and part of the Java SE platform, version 7
    • Since 1.6--New in the JDBC 4.0 API and part of the Java SE platform, version 6
    • Since 1.4--New in the JDBC 3.0 API and part of the J2SE platform, version 1.4
    • Since 1.2--New in the JDBC 2.0 API and part of the J2SE platform, version 1.2
    • Since 1.1 or no "Since" tag--in the original JDBC 1.0 APIs and part of the JDK?, version 1.1

Note: Many of the new features is optional; Consequently, there is some variation in drivers and the features they support. Always check the your driver ' s documentation to see whether it supports a feature before you try to use it.

Note: The class SQLPermission is added in the Java 2 SDK, Standard Edition, version 1.3 release. This class was used to prevent unauthorized access to the logging stream associated DriverManager with the, which may contain infor Mation such as table names, column data, and so on.

What the java.sqlPackage Contains

The package java.sql contains API for the following:

  • Making a connection with a database via the  drivermanager  facility
    • Drivermana GER  class--Makes a connection with a driver
    • sqlpermission  class--Provides per Mission when code running within a Security Manager, such as a applets, attempts to set up a logging stream through THE&NB Sp DriverManager
    • Driver  interface--provides the API for registering and connecting drivers based on JDBC technology ("JDBC drivers"); Generally used only by the  DriverManager  class
    • driverpropertyinfo  class--Provides properties for a JDBC driver; Not used by the general user
  • Sending SQL statements to a database
    • Statement--Used to send basic SQL statements
    • PreparedStatement--Used to send prepared statements or basic SQL statements (derived from Statement )
    • CallableStatement--Used to called database stored procedures (derived from PreparedStatement )
    • ConnectionInterface--Provides methods for creating statements and managing connections and their properties
    • Savepoint--Provides savepoints in a transaction
  • Retrieving and updating the results of a query
    • ResultSetInterface
  • Standard mappings for SQL types to classes and interfaces in the Java programming language
    • Arrayinterface--Mapping for SQLARRAY
    • Blobinterface--Mapping for SQLBLOB
    • Clobinterface--Mapping for SQLCLOB
    • DateClass--Mapping for SQLDATE
    • NClobinterface--Mapping for SQLNCLOB
    • Refinterface--Mapping for SQLREF
    • RowIdinterface--Mapping for SQLROWID
    • Structinterface--Mapping for SQLSTRUCT
    • SQLXMLinterface--Mapping for SQLXML
    • TimeClass--Mapping for SQLTIME
    • TimestampClass--Mapping for SQLTIMESTAMP
    • TypesClass--Provides constants for SQL types
  • Custom Mapping an SQL user-defined type (UDT) to a class in the Java programming language
    • SQLDataInterface--Specifies the mapping of a UDT to an instance of this class
    • SQLInputInterface--Provides methods for reading UDTs attributes from a stream
    • SQLOutputInterface--Provides methods for writing UDTs attributes back to a stream
  • Metadata
    • DatabaseMetaDataInterface--Provides information about the database
    • ResultSetMetaDataInterface--Provides information about the columns of a ResultSet object
    • ParameterMetaDataInterface--Provides information about the parameters to PreparedStatement commands
  • Exceptions
    • SQLException--thrown by most methods when there are a problem accessing data and by some methods for other reasons
    • SQLWarning--thrown to indicate a warning
    • DataTruncation--thrown to indicate the data may be been truncated
    • BatchUpdateException--thrown to indicate and not all commands in a batch update executed successfully
java.sqland javax.sqlFeatures introduced in the JDBC 4.3 API
    • Added Support Sharding
    • Enhanced to being Connection able to provide hints to the driver this a request, an independent unit of work, is beginning or Endi Ng
    • Enhanced to DatabaseMetaData determine if sharding is supported
    • Added the method drivers to DriverManager return a Stream of the currently loaded and available JDBC drivers
    • Added Support-to- Statement enquoting literals and simple identifiers
    • Clarified the Java SE version that methods were deprecated
java.sqland javax.sqlFeatures introduced in the JDBC 4.2 API
    • Added JDBCType enum and SQLType interface
    • Support for in REF CURSORSCallableStatement
    • DatabaseMetaDataMethods to return maximum Logical LOB size and if Ref Cursors is supported
    • Added support for large update counts
java.sqland javax.sqlFeatures introduced in the JDBC 4.1 API
    • Allow Connection , and objects to is used with the ResultSet Statement try-with-resources statement
    • Support added to and to CallableStatement ResultSet specify the Java type to convert to via the getObject method
    • DatabaseMetaDataMethods to return Pseudocolumns and if a generated key are always returned
    • Added support Connection To specify a database schema, abort and timeout a physical connection.
    • Added support to close a Statement object when its dependent objects has been closed
    • Support for obtaining the parent logger for a Driver , DataSource , and ConnectionPoolDataSourceXADataSource
java.sqland javax.sqlFeatures introduced in the JDBC 4.0 API
  • Auto Java.sql.Driver Discovery--no longer need to load a java.sql.Driver class viaClass.forName
  • National Character Set Support added
  • Support added for the sql:2003 XML data type
  • SQLException Enhancements--Added support for cause chaining; New SQLExceptions added for common SQLState class value codes
  • Enhanced BLOB/CLOB functionality--support provided to create and free a Blob/clob instance as well as additional methods Added to improve accessibility
  • Support added for accessing a SQL ROWID
  • Support added to allow a JDBC application to access a instance of a JDBC resource that have been wrapped by a vendor, Usua Lly in an application server or connection pooling environment.
  • Availability to being notified when a that's PreparedStatement associated with a have PooledConnection been closed or the driver determines is inval Id
java.sqland javax.sqlFeatures introduced in the JDBC 3.0 API
  • Pooled statements--reuse of statements associated with a pooled connection
  • Savepoints--Allow a transaction to being rolled back to a designated savepoint
  • Properties defined for ConnectionPoolDataSource --Specify how connections is to be pooled
  • Metadata for parameters of a PreparedStatement object
  • Ability to retrieve values from automatically generated columns
  • Ability to has multiple ResultSet objects returned from CallableStatement objects open at the same time
  • Ability to identify parameters to objects by name as well as by CallableStatement index
  • ResultSetHoldability--Ability to specify whether cursors should is held open or closed at the end of a transaction
  • Ability to retrieve and update the SQL structured type instance a Ref object references
  • Ability to programmatically update,, BLOB CLOB ARRAY , and REF values.
  • Addition of the java.sql.Types.DATALINK data type--allows JDBC drivers access to objects stored outside a data source
  • Addition of metadata for retrieving SQL type hierarchies
java.sqlFeatures introduced in the JDBC 2.1 Core API
    • Scrollable result sets--using new methods in the interface and the cursor to being ResultSet moved to a particular row or To a position relative to their current position
    • Batch Updates
    • Programmatic updates--using ResultSet Updater Methods
    • New Data types--interfaces Mapping the SQL3 data types
    • Custom Mapping of user-defined types (UDTs)
    • Miscellaneous features, including performance hints, the use of character streams, full precision for java.math.BigDecimal values, Additi Onal security, and support for time zones in date, time, and timestamp values.
javax.sqlFeatures introduced in the JDBC 2.0 Optional package API
    • The DataSource interface as a means of making a connection. The Java naming and Directory Interface? (JNDI) is used-registering a DataSource object with a naming service and also for retrieving it.
    • Pooled connections--allowing connections to be used and reused
    • Distributed transactions--allowing a transaction to span diverse DBMS servers
    • RowSetTechnology--providing a convenient means of handling and passing data
Custom Mapping of UDTs

A user-defined type (UDT) defined in SQL can is mapped to a class in the Java programming language. An SQL structured type or an SQL type is the UDTs that is May DISTINCT custom mapped. The following three steps set up a custom mapping:

    1. Defining the SQL structured type or DISTINCT type in SQL
    2. Defining the class in the Java programming language to which the SQL UDT would be mapped. This class must implement the SQLData interface.
    3. Making an entry in a Connection object ' s type, map, contains, and things:
      • The fully-qualified SQL name of the UDT
      • The object for the class, that Class implements the SQLData interface

When these is in place for a UDTs, calling the methods ResultSet.getObject or on that CallableStatement.getObject UDT would automatically retrieve the custom m Apping for it. Also, the PreparedStatement.setObject method would automatically map the object back to its SQL type to store it in the data source.

Package specification
    • JDBC 4.3 specification
Related documentation
      • Lesson:jdbc Basics (The Javaxx tutorials > JDBC? Database Access)
      • Jdbc? API Tutorial and Reference, third Edition

Package java.sql

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.