如何从 jdbc 代码传递数组对象
我在 informix 11.5 数据库中有一个存储过程 get_data(estargs set(char(1000) not null)) 。我必须使用这个存储过程才能从数据库中获取值。
我尝试使用这种方式,但失败了:
conn = dataSource.getConnection();
String [] arrayObj={"and code = 'Value1'","and lmt= 10000.000"};
CallableStatement test=conn.prepareCall("{call get_data(?)}");
test.setObject(1, arrayObj);
test.execute();
ResultSet testrs = test.getResultSet();
while (testrs.next()) {
int data = testrs.getInt(1);
System.out.println(data);
}
这不起作用。你认为我做错了什么?
I have a stored procedure get_data(estargs set(char(1000) not null)) in the informix 11.5 database. I have to use this stored procedure in order to get a value from the database.
I tried using this way but it fails:
conn = dataSource.getConnection();
String [] arrayObj={"and code = 'Value1'","and lmt= 10000.000"};
CallableStatement test=conn.prepareCall("{call get_data(?)}");
test.setObject(1, arrayObj);
test.execute();
ResultSet testrs = test.getResultSet();
while (testrs.next()) {
int data = testrs.getInt(1);
System.out.println(data);
}
This is not working. What do you think I am doing wrong?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
那是不可能的。替换
为
并替换
为
相关问题:
更新:使其更加“动态”,您希望借助以下两个实用方法自己生成和填充占位符:
可以如下使用:
That's not possible. Replace
by
and replace
by
Related question:
Update: make it all more "dynamically", you'd like to generate and populate the placeholders yourself with help of the following two utility methods:
which can be used as follows:
您是否尝试过使用 java.sql.Array?
Have you tried using java.sql.Array?