How can I set a String[] parameter to a native query?

前端 未结 4 2186
野的像风
野的像风 2020-12-17 22:44

This is my PostgreSQL function:

salvarArquivoGeometricoCasoZeroPOINT
(dimensao text,tableName text,tuplas text[],srid text)

It has a

4条回答
  •  我在风中等你
    2020-12-17 23:26

    It seems EclipseLink doesn't fix the bug 361701. mentioned by @Craig Ringer.

    The only way to pass a String[] as a parameter is using the JDBC without EclipseLink. Check the code.

    Connection con = ConnectionHelper.getConnection();
            Array tArray = con.createArrayOf("text", tuplas);
            PreparedStatement pstm =
            con.prepareStatement("select salvarArquivoGeometricoCasoZeroPOINT(?,?,?,?)");
            pstm.setString(1,arquivo.getGeoType());
            pstm.setString(2,arquivo.getTable());
            pstm.setArray(3,tArray);
            pstm.setString(4,arquivo.getSrid());
            rs = pstm.executeQuery();
    

    ConnectionHelper it's my java.sql.Connection class.

    I appreciate the help of you guys: @Craig Ringer and @Matt Ball, Thanks.

提交回复
热议问题