The mapping extensions
To direct the driver to map to a certain data type (so there is no ambiguity in UPDATE statements and WHERE clauses), you can use extensions to the PreparedStatement.setXXX() methods. The only data types that might have ambiguity are boolean, lvarchar, text, byte, BLOB, and CLOB.
To use these extended methods, you
must cast your PreparedStatement references to IfmxPreparedStatement.
For example, the following code casts the statement variable p_stmt to IfmxPreparedStatement to
call the IfxSetObject() method and insert the contents
of a file as a large object of type CLOB. IfxSetObject() is
defined as I:
public void IfxSetObject(int i, Object x, int scale, int ifxType) throws SQLException public void IfxSetObject(int i, Object x, int ifxType) throws SQLexception
The code is:
File file = new File("sblob_06.dat"); int fileLength = (int)file.length(); byte[] buffer = new byte[fileLength]; FileInputStream fin = new FileInputStream(file); fin.read(buffer,0,fileLength); String str = new String(buffer); writeOutputFile("Prepare"); PreparedStatement p_stmt = myConn.prepareStatement ("insert into sblob_t20(c1) values(?)"); writeOutputFile("IfxSetObject"); ((IfmxPreparedStatement)p_stmt).IfxSetObject(1,str,30,IfxTypes.IFX _TYPE_CLOB);
For the IfmxPreparedStatement.IfxSetObject extension, you cannot simply overload the method signature with an added ifxType parameter, because such overloading creates method ambiguity. You must name the method to IfxSetObject instead.