2 回答
TA贡献1775条经验 获得超8个赞
经过两天的搜索,主要问题是 datumnArray 是 ???。这意味着 oracld db 和 jdbc 与其字符集不匹配。添加此代码后。
String s1 = new String(account.get(0).getBytes(), Charset.forName("ISO-8859-1"));
String [] name = new String[]{s1};
//oracle.sql.ArrayDescriptor arrayDescriptor = new ArrayDescriptor("ARRAY_VARCHAR2",connection);
oracle.sql.ARRAY a = connection.createARRAY("ARRAY_VARCHAR2", name);
并将这个库添加到maven中
<dependency>
<groupId>com.oracle</groupId>
<artifactId>orai18n</artifactId>
<version>11.1.0.7.0</version>
</dependency>
这对我有用。我认为他们都是解决问题的关键。下面的图片开头。
TA贡献1891条经验 获得超3个赞
使用oracle.sql.ARRAYandoracleConnection.setARRAY()而不是java.sql.Arrayand javaConnection.setArray():
Connection connection = JdbcConnection.getInstance().createConnection();
OracleConnection oconnection = (OracleConnection) connection.unwrap( oracle.jdbc.OracleConnection.class );
String [] name = new String[]{"20206643799002684001","20206643799002684001"};
ArrayDescriptor arrDec = ArrayDescriptor.createDescriptor("ARRAY_VARCHAR2",oconnection);
ARRAY arr = new ARRAY(arrDec,oconnection,name);
/*
* Or
* ARRAY arr = oconnection.createARRAY("ARRAY_VARCHAR2", name);
*/
OracleCallableStatement callableStatement
= (OracleCallableStatement) oconnection.prepareCall("{call bss_acc.ACC_STATEMENT(?,?,?,?)}");
callableStatement.setDate(1,date);
callableStatement.setDate(2,dateL);
callableStatement.setARRAY(3,arr);
callableStatement.setString(4,this.branchId);
callableStatement.execute();
添加回答
举报