官术网_书友最值得收藏!

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.

主站蜘蛛池模板: 来宾市| 岫岩| 印江| 房山区| 瓮安县| 衡山县| 宁国市| 遂平县| 漯河市| 焉耆| 广南县| 万载县| 新民市| 乌鲁木齐市| 招远市| 甘南县| 北票市| 石楼县| 清徐县| 阳原县| 亚东县| 桐乡市| 合川市| 成武县| 察隅县| 双江| 冀州市| 攀枝花市| 兴安县| 湖南省| 江西省| 榆社县| 开远市| 永济市| 光山县| 永德县| 大田县| 潜山县| 馆陶县| 奉新县| 扶余县|