当前位置: 代码迷 >> J2SE >> 帮小弟我看个java调用oracle存储过程,并且传递数组的例子好吗
  详细解决方案

帮小弟我看个java调用oracle存储过程,并且传递数组的例子好吗

热度:289   发布时间:2016-04-24 17:56:44.0
帮我看个java调用oracle存储过程,并且传递数组的例子好吗
create   or   replace   type   ARR   as   table   of   VARCHAR2(200)   NOT   NULL;

import   java.sql.*;
import   java.util.*;
import   oracle.jdbc.driver.*;
import   oracle.sql.*;

public   class   test
{
public   static   void   main(String   args[])   throws   Exception
{
DriverManager.registerDriver(new   oracle.jdbc.driver.OracleDriver());
Connection   conn   =   DriverManager.getConnection( "jdbcracle:thin:@192.168.1.1:1521:test ", "user ", "pass ");
String   a[]={ "3 ", "2 ", "100 "};
ArrayDescriptor   descriptor   =   ArrayDescriptor.createDescriptor( "ARR ",conn);
ARRAY   array_to_pass   =   new   ARRAY(descriptor,conn,a);
}
}

我这里还没有调用存储过程就不对了

编译可以通过,
Exception   in   thread   "main "   java.sql.SQLException:   Non   supported   character   set:   o
racle-character-set-178
at   oracle.gss.util.NLSError.throwSQLException(NLSError.java:46)
at   oracle.sql.CharacterSetUnknown.failCharsetUnknown(CharacterSetFactory
Thin.java:171)
at   oracle.sql.CharacterSetUnknown.convert(CharacterSetFactoryThin.java:1
35)
at   oracle.sql.CHAR. <init> (CHAR.java:159)
at   oracle.sql.CHAR. <init> (CHAR.java:183)
at   oracle.jdbc.oracore.OracleTypeCHAR.toDatum(OracleTypeCHAR.java:162)
at   oracle.jdbc.oracore.OracleType.toDatumArray(OracleType.java:166)
at   oracle.jdbc.oracore.OracleTypeCHAR.toDatumArray(OracleTypeCHAR.java:2
08)
at   oracle.sql.ArrayDescriptor.toOracleArray(ArrayDescriptor.java:1517)
at   oracle.sql.ARRAY. <init> (ARRAY.java:117)
at   test.main(test.java:19)



------解决方案--------------------
不支持oracle-character-set-178
你可以试试使用java标准库的数组;或者将数组先转码。
代码迷推荐解决方案:oracle存储过程,http://www.daimami.com/oracle-develop/177537.html
  相关解决方案