JDBC support for DESCRIBE INPUT
The SQL 92 and 99 standards specify a DESCRIBE INPUT statement for Dynamic SQL. Version 9.4 of HCL Informix® provides support for this statement. (For more information about SQL standards, syntax, and this statement, see Informix® Guide to SQL: Syntax.)
The JDBC 3.0 specification introduces a ParameterMetaData class and methods that correspond to DESCRIBE INPUT support.
The Informix® JDBC Driver implements the java.sql.ParameterMetaData class. This interface is used for describing input parameters in prepared statements. The method getParameterMetaData() has been implemented to retrieve the metadata for a particular statement.
The ParameterMetaData class and the getParameterMetaData() method are part of the JDBC 3.0 API and are included as interfaces in J2SDK1.4.0. Details of these interfaces are specified in the JDBC 3.0 specification.
Return type | Method | Description |
---|---|---|
int | getParameterLength (int param) | Retrieves parameters length |
int | getParameterExtendedId (int param) | Retrieves parameters extended ID |
java.lang.String | getParameterExtendedName (int param) | Retrieves parameters extended name |
java.lang.String | getParameterExtendedOwnerName (int param) | Retrieves parameters extended owner name of the type |
int | getParameterSourceType (int param) | Retrieves parameters SourceType |
int | getParameterAlignment (int param) | Retrieves parameters alignment |
. . .
try
{
PreparedStatement pstmt = null;
pstmt = myConn.prepareStatement(
"select * from table_1 where int_col = ? "
+"and string_col = ?");
ParameterMetaData paramMeta = pstmt.getParameterMetaData();
int count = paramMeta.getParameterCount();
System.out.println("Count : "+count);
for (int i=1; i <= count; i++)
{
System.out.println("Parameter type name : "
+paramMeta.getParameterTypeName(i));
System.out.println("Parameter type : "
+paramMeta.getParameterType(i));
System.out.println("Parameter class name : "
+paramMeta.getParameterClassName(i));
System.out.println("Parameter mode : "
+paramMeta.getParameterMode(i));
System.out.println("Parameter precision : "
+paramMeta.getPrecision(i));
System.out.println("Parameter scale : "
+paramMeta.getScale(i));
System.out.println("Parameter nullable : "
+paramMeta.isNullable(i));
System.out.println("Parameter signed : "
+paramMeta.isSigned(i));
}
. . .