- JDBC 4.0 and Oracle JDeveloper for J2EE Development
- Deepak Vohra
- 628字
- 2021-08-25 18:08:46
Enhanced Data Type Support
JDBC 4.0 has added support for some new SQL data types. The ROWID
SQL data type, which identifies a row in a table, is mapped to the java.sql.RowId
Java data type. The Reader method, readRowId()
has been added to the SQLInput
interface, and the writer method, writeRowId()
, has been added to the SQLOutput
interface to read, and write ROWID
values.
In JDBC 3.0, JDBC drivers supported only Unicode character set. SQL: 2003 standard has added support for SQL types, NCAHR, NVARCHAR, LONGVARCHAR
, and NCLOB
in which values are encoded using the National Character Set (NCS). The National Character Set SQL data type values were converted to the Unicode Character Set values with a JDBC 3.0 driver. The NCS data types can be more suitable if extensive character processing operations are required. Support for National Character Set database data types, NCHAR, NVARCHAR, LONGNVARCHAR
, and NCLOB
have been added in JDBC 4.0.
Setter methods, setNString(), setNCharacterStream()
, and setNClob()
have been added to the PreparedStatement
and CallableStatement
interfaces. Getter method, getNString(), getNCharacterStream()
, and getNClob()
have been added to the CallableStatement
and ResultSet
interfaces. Updater methods, updateNString(), updateNCharacterStream()
, and updateNClob()
have been added to the ResultSet
interface. To create a NClob
object, createNClob()
method has been added to the Connection
interface. Reader methods, readNString()
and readNClob()
have been added to the SQLInput
interface to read the NCHAR, NVARCHAR, LONGNVARCHAR
, and NCLOB
values. Writer methods, writeNClob()
and writeNString()
have been added to the SQLOutput
interface to write the NCHAR, NVARCHAR, LONGNVARCHAR
, and NCLOB
values.
In JDBC 4.0, support for BLOB
and CLOB
SQL data types have been enhanced. To create java.sql.Blob
and java.sql.Clob
objects, methods such as createBlob()
and createClob()
have been added to the Connection
interface. In the PreparedStatement
and CallableStatement
interfaces, setBlob()
method has been overloaded to set the Blob
values from an InputStream
, and setClob()
method has been overloaded to set the Clob
values from a Reader
. In the ResultSet
interface, the updater method, updateBlob()
, has been overloaded to update a column from an InputStream
and the updater method, updateClob()
, has been overloaded to update a column from a Reader
. To free resources in Blob
and Clob
objects, a method, free()
, has been added to the Blob
and Clob
interfaces.
The setAsciiStream, setBinaryStream
, and setCharacterStream
methods in the CallableStatement
and PreparedStatement
interfaces have been overloaded. These interfaces have been overloaded to support the length
parameter of type long
in addition to the length
parameter of type int
. The length
parameter specifies the length in bytes or characters of the InputStream
or Reader
object. Also, the setAsciiStream, setBinaryStream
, and setCharacterStream
methods in the CallableStatement
and PreparedStatement
interfaces have been overloaded with versions without the length
parameter.
The setBlob()
method in the CallableStatement
and PreparedStatement
interfaces has been overloaded with the other two methods to set parameter values from the InputStream
object, one with a length
parameter for the length of the binary stream, and the other without a length
parameter. If the InputStream
length does not match the specified length, an SQLException
is generated. The setClob()
method in the CallableStatement
and PreparedStatement
interfaces has been overloaded with other two methods to set parameter values from the Reader
object, one with a length
parameter for the number of characters in the Reader
object and the other without a length
parameter.
If the number of characters in the Reader
object does not match the specified length, an SQLEception
is generated. Similar to the setter methods in the PreparedStatement/CallableStatement
, the updateAsciiStream, updateBinaryStream, updateBlob, updateCharacterStream
, and updateClob
methods in the ResultSet
interface have been overloaded. Unlike the setBlob
and setClob
methods of the PreparedStatement
and CallableStatement
interfaces, the updateBlob
and updateClob
methods of the ResultSet
interface do not generate an SQLException
, if the InputStream/Reader
length does not match the specified length.
- Getting Started with Microsoft Application Virtualization 4.6
- 從零開始學LATEX
- 中文版Maya 2012實用教程(第2版)
- 鍵盤錄入技術(第2版)
- CorelDRAW服裝設計實用教程(第四版)
- UG NX 12.0實例寶典
- SPSS 28.0統計分析從入門到精通(升級版)
- 3ds Max 2015中文版從入門到精通
- BlackBerry Enterprise Server 5 Implementation Guide
- Excel 2013公式·函數與數據分析
- 手機/電腦雙平臺剪映短視頻后期編輯從新手到高手
- 圖像顯著區域提取方法及其應用研究
- SolidWorks三維設計及工程圖速成
- OpenGL 4.0 Shading Language Cookbook
- MSC Fatigue疲勞分析標準教程