Use JDBI to get Postgres Array Data

自闭症网瘾萝莉.ら 提交于 2019-12-08 02:39:33

问题


I have a java program using JDBI (a JDBC wrapper) to access a PostgreSQL database. One of the columns is of the array data type (mycolumn integer[]).

What the heck to I use in my mapper class? I thought resultSet.getArray("mycolumn") would be the right thing to do, but I'm not sure how to get the data out of the java.sql.Array object that gets returned.

Any hints or good links on how to do this?


回答1:


        Array array = resultSet.getArray("mycolumn");
        return nonNull(array) ? (Integer[])array.getArray() : null ;


来源:https://stackoverflow.com/questions/16093398/use-jdbi-to-get-postgres-array-data

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!