只要没有OUT参数,就会调用过程,但只要给出OUT参数,就会发生以下错误:
java.sql.SQLException:Routine(test)无法解析。
以下是我的代码:
Class.forName("com.informix.jdbc.IfxDriver");
java.sql.Connection connection =DriverManager.getConnection("jdbc:informix-sqli://server_details");
CallableStatement stmt = null;
String sql = "{call test (?, ?)}";
stmt = connection.prepareCall(sql);
stmt.registerOutParameter(1, java.sql.Types.VARCHAR);
stmt.registerOutParameter(2, java.sql.Types.VARCHAR);
stmt.execute();
答案 0 :(得分:1)
我使用JDBC CallableStatement
调用的两个OUT参数的Informix过程的简单示例有效:
db = DriverManager.getConnection(db_url, usr, passwd)
c = db.createStatement()
try:
c.execute('DROP PROCEDURE test_out_params;')
except:
pass
c.execute("""CREATE PROCEDURE test_out_params(OUT arg1 VARCHAR(200), OUT arg2 VARCHAR(200))
LET arg1 = 'arg1';
LET arg2 = 'arg2';
END PROCEDURE;""")
stmt = db.prepareCall("{call test_out_params (?, ?)}")
stmt.registerOutParameter(1, Types.VARCHAR)
stmt.registerOutParameter(2, Types.VARCHAR)
stmt.executeQuery()
a1 = stmt.getString(1)
a2 = stmt.getString(2)
print('call result: %s %s\n' % (a1, a2))
我在这段代码中使用了Jython,我得到了:
call result: arg1 arg2
我认为您应该添加test()
过程的简化源以及有关您的环境的更多详细信息,尤其是Informix服务器版本和JDBC驱动程序版本。