无法转换为内部表示(oracle.sql.ARRAY)

时间:2015-12-28 13:32:00

标签: java oracle12c

我想在Object[] Array中转换oracle.sql.ARRAY,因此我可以将其插入到我的Oracle数据库(12c)中。

public class Datatransfer{

  public static void main(String[] args) throws SQLException, ClassNotFoundException{

    Connection accessConn = null;
    Connection oracleConn = null;
    Statement stmt = null;
    ResultSet rs = null;
    String mySelectSQL = "Select * from Supplier";

    try{
        oracleConn = DBConnection.connOracle();
        accessConn = DBConnection.connAccess();
        stmt = accessConn.createStatement();
        rs = stmt.executeQuery(mySelectSQL);

        while(rs.next()){
           do_something...

           Object[] addressArray = {rs.getString("Street"),
                                   rs.getString("Location"),
                                   rs.getString("Region"),
                                   rs.getString("Postcode"),
                                   rs.getString("Country")};
           oracle.sql.ARRAY myAddressArray =
                        ((oracle.jdbc.OracleConnection)oracleConn).
                        createARRAY("ADDRESS_ARRAY", addressArray);

        do_something...

    }
    catch(SQLException | ClassNotFoundException e)
    {e.printStrackTrace();}
    finally{
      Close_all_Connection ...
    }
}

此时我得到以下SQLException:

java.sql.SQLException: Fail to convert to internal representation: 49 Gilbert St.
at oracle.jdbc.oracore.OracleTypeADT.toDatum(OracleTypeADT.java:339)
at oracle.jdbc.oracore.OracleTypeADT.toDatumArray(OracleTypeADT.java:372)
at oracle.jdbc.oracore.OracleTypeUPT.toDatumArray(OracleTypeUPT.java:110)
at oracle.sql.ArrayDescriptor.toOracleArray(ArrayDescriptor.java:1238)
at oracle.sql.ARRAY.<init>(ARRAY.java:103)
at oracle.jdbc.driver.PhysicalConnection.createARRAY
(PhysicalConnection.java:8649)
at nsd.datatrans.Datatransfer.main(Datatransfer.java:64)

那我该怎么办?

0 个答案:

没有答案