值java.sql.SQLException:无法转换为内部重新presentation:当通过的ArrayList到Oracle.sql.ARRAY [英] java.sql.SQLException: Fail to convert to internal representation: while passing ArrayList to Oracle.sql.ARRAY

查看:160
本文介绍了值java.sql.SQLException:无法转换为内部重新presentation:当通过的ArrayList到Oracle.sql.ARRAY的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是我的code结果

List<String> listA = new ArrayList<String>(0);
String[] arrA = new String[100];
listA.add("aaa");
listA.add("bbb");
arrA[0]="aaa";
arrA[1]="bbb";
conn = DriverManager.getConnection(URL, USER, PASS);
oracle.jdbc.OracleConnection oraConn = (oracle.jdbc.OracleConnection) conn;
ArrayDescriptor des = ArrayDescriptor.createDescriptor("ARRAY_TABLE", oraConn);
//*****************
ARRAY array_to_pass1 = new ARRAY(des, conn, arrA );//* exception
CallableStatement cstm = (OracleCallableStatement) conn.prepareCall("{call xyz.procedure1(?,?)}");
cstm.setArray(1, array_to_pass1);
cstm.setInt(2, 1);

结果这是工作的罚款,但是当我传递的listA的ARRA而不是数组constructor..it SQL例外上面扔。我想传递的,而不是String []数组的ArrayList


this is working fine but when I pass listA instead of arrA to ARRAY constructor..it is throwing above sql exception.. I want to pass Arraylist instead of string[] array

推荐答案

行前将您的列表,以数组

Convert your list to array before the line

ARRAY array_to_pass1 = new ARRAY(des, conn, arrA );

您可以添加/在此之前从列表中删除的项目。

You can add/remove items from the list prior to this.

String[] arrA= new String[listA.size()];
arrA= listA.toArray(arrA);

这篇关于值java.sql.SQLException:无法转换为内部重新presentation:当通过的ArrayList到Oracle.sql.ARRAY的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆