IBM Support

Error -4461 : Invalid Data conversion in Type 4 JCC connection when using setObject() function

Technote (FAQ)


Using Java:setObject function for character, string data types returns an error -4461 - Invalid data conversion, when using JCC Type 4 connection while the same succeeds when using a JCC Type 2 connection.


The reason this error is returned in Type 4 implementation of jdbc
driver and not in Type 2 is because, Type 4 JDBC driver is a pure Java
native driver that strictly follows the Java JDBC specifications,
whereas Type2 JDBC driver is a CLI based driver which is less strict
with data type conversions.

Here is a small test program to check and rectify the error :

<test program snip>
String url = "jdbc:db2://";
Connection con = DriverManager.getConnection(url,"userid","mypwd");
System.out.println("DB Sample Connected");
PreparedStatement pstmt =
con.prepareStatement("INSERT INTO table_name VALUES (?)");
// pstmt.setString (2, "P"); ===> SUCCESS
pstmt.setObject (2, new Character('P'), Types.CHAR ); ===> FAILs
pstmt.execute ();
catch (Exception ex) {
System.out.println("Exception: " + ex);

Execution of this program throws the following error :

[jcc][1091][10417][3.64.96] Invalid data conversion: Parameter instance
P is invalid for the
requested conversion. ERRORCODE=-4461, SQLSTATE=42815
at MAINCLASS.main(

When pstmt.setObject is changed to pstmt.setString (commented line above the failing one), it inserts "P" successfully in the table.


The solution is to use the function setString in place of setObject wherever you are aware that input data is going to be a character or string.

Related information

Driver support for JDBC APIs

Document information

More support for: DB2 for Linux, UNIX and Windows
Programming Interface - JCC

Software version: 9.1, 9.5, 9.7, 9.8, 10.1

Operating system(s): AIX, HP-UX, Linux, Solaris, Windows

Reference #: 1622381

Modified date: 29 July 2013