Postgresql, JDBC, and streaming BLOBs

前端 未结 3 686
爱一瞬间的悲伤
爱一瞬间的悲伤 2021-01-07 19:13

I am trying to retrieve a blob from a postgres database using the jdbc drivers. It is too big to have in memory so I want to stream it as a download. I tried using the get

3条回答
  •  夕颜
    夕颜 (楼主)
    2021-01-07 19:36

    byte [] b = null;
    while (m_ResultSet.next()) {
        for (int i = 1; i <= m_ResultSet.getMetaData().getColumnCount(); i++) {
            b =  m_ResultSet.getBytes(i);
        }
    }
    String str = "";
    for (byte i : b){
        str+=(char)i;
    }
    

提交回复
热议问题