APIdia Launch Partner
Top Description Interfaces Classes Enums
module java.sql

Package 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 API includes a framework whereby different drivers can be 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 source with a tabular format. The reader/writer facility, available through the javax.sql.RowSet group of interfaces, can be customized to use and update data from a spread sheet, flat file, or any other tabular data source.

What the JDBC 4.5 API Includes

The JDBC 4.5 API includes both the java.sql package, referred to as the JDBC core API, and the javax.sql package, referred to as the JDBC Optional Package API. This complete JDBC API is included in the Java Standard Edition (Java SE). The javax.sql package extends the functionality of the JDBC API from a client-side API to a server-side API, and it is an essential part of the Java Enterprise Edition (Java EE) technology.

Versions

The JDBC 4.5 API incorporates all the previous JDBC API versions:

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

Note

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

What the java.sql Package Contains

The java.sql package contains API for the following:

java.sql and javax.sql Features Introduced in the JDBC 4.5 API

java.sql and javax.sql Features Introduced in the JDBC 4.4 API

java.sql and javax.sql Features Introduced in the JDBC 4.3 API

java.sql and javax.sql Features Introduced in the JDBC 4.2 API

java.sql and javax.sql Features Introduced in the JDBC 4.1 API

java.sql and javax.sql Features Introduced in the JDBC 4.0 API

java.sql and javax.sql Features Introduced in the JDBC 3.0 API

java.sql Features Introduced in the JDBC 2.1 Core API

javax.sql Features Introduced in the JDBC 2.0 Optional Package API

Custom Mapping of UDTs

A user-defined type (UDT) defined in SQL can be mapped to a class in the Java programming language. An SQL structured type or an SQL DISTINCT type are the UDTs that may be 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 will be mapped. This class must implement the SQLData interface.
  3. Making an entry in a Connection object's type map that contains two things:
    • the fully-qualified SQL name of the UDT
    • the Class object for the class that implements the SQLData interface

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

Package Specification

Related Documentation

Since
1.1

Interface Summary

Modifier and TypeInterface and Description
public interface
Array

The mapping in the Java programming language for the SQL type ARRAY.

public interface
Blob

The representation (mapping) in the Java programming language of an SQL BLOB value.

public interface
CallableStatement

The interface used to execute SQL stored procedures.

public interface
Clob

The mapping in the Java programming language for the SQL CLOB type.

public interface
Connection

A connection (session) with a specific database.

public interface
ConnectionBuilder

A builder created from a DataSource object, used to establish a connection to the database that the data source object represents.

public interface
DatabaseMetaData

Comprehensive information about the database as a whole.

public interface
Driver

The interface that every driver class must implement.

public interface
DriverAction

An interface that must be implemented when a Driver wants to be notified by DriverManager.

public interface
NClob

The mapping in the Java programming language for the SQL NCLOB type.

public interface
ParameterMetaData

An object that can be used to get information about the types and properties for each parameter marker in a PreparedStatement object.

public interface
PreparedStatement

An object that represents a precompiled SQL statement.

public interface
Ref

The mapping in the Java programming language of an SQL REF value, which is a reference to an SQL structured type value in the database.

public interface
ResultSet

A table of data representing a database result set, which is usually generated by executing a statement that queries the database.

public interface
ResultSetMetaData

An object that can be used to get information about the types and properties of the columns in a ResultSet object.

public interface
RowId

The representation (mapping) in the Java programming language of an SQL ROWID value.

public interface
Savepoint

The representation of a savepoint, which is a point within the current transaction that can be referenced from the Connection.rollback method.

public interface
ShardingKey

Interface used to indicate that this object represents a Sharding Key.

public interface
ShardingKeyBuilder

A builder created from a DataSource or XADataSource object, used to create a ShardingKey with sub-keys of supported data types.

public interface
SQLData

The interface used for the custom mapping of an SQL user-defined type (UDT) to a class in the Java programming language.

public interface
SQLInput

An input stream that contains a stream of values representing an instance of an SQL structured type or an SQL distinct type.

public interface
SQLOutput

The output stream for writing the attributes of a user-defined type back to the database.

public interface
SQLType

An object that is used to identify a generic SQL type, called a JDBC type or a vendor specific data type.

public interface
SQLXML

The mapping in the JavaTM programming language for the SQL XML type.

public interface
Statement

The object used for executing a static SQL statement and returning the results it produces.

public interface
Struct

The standard mapping in the Java programming language for an SQL structured type.

public interface
Wrapper

Interface for JDBC classes which provide the ability to retrieve the delegate instance when the instance in question is in fact a proxy class.

Class Summary

Modifier and TypeClass and Description
public class
BatchUpdateException

The subclass of SQLException thrown when an error occurs during a batch update operation.

public class
DataTruncation

An exception thrown as a DataTruncation exception (on writes) or reported as a DataTruncation warning (on reads) when a data values is unexpectedly truncated for reasons other than its having exceeded MaxFieldSize.

public class
Date

A thin wrapper around a millisecond value that allows JDBC to identify this as an SQL DATE value.

pack-priv class
public class
DriverManager

The basic service for managing a set of JDBC drivers.

public class
DriverPropertyInfo

Driver properties for making a connection.

public class
SQLClientInfoException

The subclass of SQLException is thrown when one or more client info properties could not be set on a Connection.

public class
SQLDataException

The subclass of SQLException thrown when the SQLState class value is '22', or under vendor-specified conditions.

public class
SQLException

An exception that provides information on a database access error or other errors.

public class
SQLFeatureNotSupportedException

The subclass of SQLException thrown when the SQLState class value is '0A' ( the value is 'zero' A).

public class
SQLIntegrityConstraintViolationException

The subclass of SQLException thrown when the SQLState class value is '23', or under vendor-specified conditions.

public class
SQLInvalidAuthorizationSpecException

The subclass of SQLException thrown when the SQLState class value is '28', or under vendor-specified conditions.

public class
SQLNonTransientConnectionException

The subclass of SQLException thrown for the SQLState class value '08', or under vendor-specified conditions.

public class
SQLNonTransientException

The subclass of SQLException thrown when an instance where a retry of the same operation would fail unless the cause of the SQLException is corrected.

public class
SQLPermission

Deprecated for removal since 26. There is no replacement for this class.
This class was only useful in conjunction with the java.lang.SecurityManager, which is no longer supported.
public class
SQLRecoverableException

The subclass of SQLException thrown in situations where a previously failed operation might be able to succeed if the application performs some recovery steps and retries the entire transaction or in the case of a distributed transaction, the transaction branch.

public class
SQLSyntaxErrorException

The subclass of SQLException thrown when the SQLState class value is '42', or under vendor-specified conditions.

public class
SQLTimeoutException

The subclass of SQLException thrown when the timeout specified by Statement.setQueryTimeout, DriverManager.setLoginTimeout, DataSource.setLoginTimeout,XADataSource.setLoginTimeout has expired.

public class
SQLTransactionRollbackException

The subclass of SQLException thrown when the SQLState class value is '40', or under vendor-specified conditions.

public class
SQLTransientConnectionException

The subclass of SQLException for the SQLState class value '08', or under vendor-specified conditions.

public class
SQLTransientException

The subclass of SQLException is thrown in situations where a previously failed operation might be able to succeed when the operation is retried without any intervention by application-level functionality.

pack-priv class
SQLUtils

Utility class used by the Connection & Statement interfaces for their shared default methods.

public class
SQLWarning

An exception that provides information on database access warnings.

public class
Time

A thin wrapper around the java.util.Date class that allows the JDBC API to identify this as an SQL TIME value.

public class
Timestamp

A thin wrapper around java.util.Date that allows the JDBC API to identify this as an SQL TIMESTAMP value.

public class
Types

The class that defines the constants that are used to identify generic SQL types, called JDBC types.

Enum Summary

Modifier and TypeEnum and Description
public enum
ClientInfoStatus

Enumeration for status of the reason that a property could not be set via a call to Connection.setClientInfo

public enum
JDBCType

Defines the constants that are used to identify generic SQL types, called JDBC types.

public enum
PseudoColumnUsage

Enumeration for pseudo/hidden column usage.

public enum
RowIdLifetime

Enumeration for RowId life-time values.