IfxTypes java.sql.Types and setObject()
Posted in 2000
Topics: Error Codes & Troubleshooting, Connectivity: ODBC / JDBC / .NET, Data Types & Schema Design, Java & JDBC Development, Versions, Editions & End-of-Life
IDS 9.21.UC1 with Informix JDBC Driver Version 2.11.JC1 A question on java.sql.Types related to com.informix.lang.IfxTypes Assume a preparedStatement pStmt is initialised with a placeholder (?) as parameter 1. The type of param 1 is only determined at runtime, so using a setXXX (setString if it is a String) is not suitable. Rather, setObject(int param, Object value, int sqlType) is used. An HashMap is built mapping java Class to java.sql.Types, e.g. String.class - Types.VARCHAR int.class - Types.INTEGER etc.. So, at runtime, reflection is used on the object to determine its Class to lookup the Types Straight java works, however every attempt to use IfxTypes fails, i.e. int ifxType = IfxTypes.FromJavaToIfxType(javaType); returns 0 (zero IfxName=char) when javaType java.lang.String is the Class name string provided. When this is presented to the preparedStatement via setObject, results in SQL exception: Unknown object type: SQLState IX000 : error code: -79728 Am I using IfxTypes incorrectly by converting java class name to IfxTypes to use in setObject ? Are there any examples/samples/docs that I could examine for IfxTypes ? Any thoughts are appreciated. Sent via Deja.com http://www.deja.com/ Before you buy.