您还可以使用DatabaseMetaData来获取您想要的信息。
一个获取所有存储过程及其参数的简单程序是这样的:
import java.sql.Connection;
import java.sql.DatabaseMetaData;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.SQLException;
public class Main {
public static void main(String[] args) {
try {
Class.forName ("com.informix.jdbc.IfxDriver");
} catch (ClassNotFoundException e) {
System.out.println(e);
return;
}
try {
Connection conn = DriverManager.getConnection("jdbc:informix-sqli://.........");
ResultSet rsProcs;
DatabaseMetaData dbMeta = conn.getMetaData();
rsProcs = dbMeta.getProcedures(null, null, null);
while (rsProcs.next()) {
String procName = rsProcs.getString("PROCEDURE_NAME");
System.out.println(procName);
ResultSet rsParams = dbMeta.getProcedureColumns(null, null, procName, null);
while (rsParams.next()) {
System.out.println("Param " + rsParams.getString("ORDINAL_POSITION") + " :" +
" Name: " + rsParams.getString("COLUMN_NAME") +
" Type: " + rsParams.getString("COLUMN_TYPE") +
" Data Type: " + rsParams.getString("DATA_TYPE"));
}
System.out.println("");
rsParams.close();
}
rsProcs.close();
conn.close();
} catch (SQLException e) {
System.out.println(e);
}
}
}
检查SQL 数据类型值的常量字段值的 java.sql.Types 部分。