Here you can find the source of getArrayFromResultSet(ResultSet rs, String field)
Parameter | Description |
---|---|
rs | ResultSet |
field | Field we want to obtain the value from |
public static List<String> getArrayFromResultSet(ResultSet rs, String field)
//package com.java2s; //License from project: Apache License import java.sql.Array; import java.sql.ResultSet; import java.util.ArrayList; import java.util.Arrays; import java.util.List; public class Main { /**//from w ww.ja v a 2 s . co m * Returns a string list corresponding to the given field on the given * ResultSet. If the value cannot be parsed to an array, or does not exist, it * returns an empty value. * * @param rs * ResultSet * @param field * Field we want to obtain the value from * @return Long value if the field exists and can be parsed to Long. Null otherwise. */ public static List<String> getArrayFromResultSet(ResultSet rs, String field) { List<String> result; try { Array arrayChunks = rs.getArray(field); String[] chunks = (String[]) arrayChunks.getArray(); result = Arrays.asList(chunks); if (result.contains(null)) { result = new ArrayList<String>(); } } catch (Exception e) { result = new ArrayList<String>(); } return result; } }