Android
5
Вклад в тег
private ArrayList<HashMap<String, Object>> resultSetToArrayList(ResultSet rs) throws SQLException {
ResultSetMetaData md = rs.getMetaData();
int columns = md.getColumnCount();
ArrayList<HashMap<String, Object>> list = new ArrayList<>();
while (rs.next()) {
HashMap<String, Object> row = new HashMap<>(columns);
for (int i = 1; i <= columns; ++i) {
row.put(md.getColumnName(i), rs.getObject(i));
}
list.add(row);
}
return list;
}
private ArrayList<Object> resultSetGetColToArrayList(ResultSet rs) throws SQLException {
ArrayList<Object> list = new ArrayList<>();
while (rs.next()) {
list.add(rs.getObject(1));
}
return list;
}
private HashMap<String, Object> resultSetGetRowToHashmap(ResultSet rs) throws SQLException {
ResultSetMetaData md = rs.getMetaData();
int columns = md.getColumnCount();
HashMap<String, Object> row = new HashMap<>(columns);
if (rs.next()) {
for (int i = 1; i <= columns; ++i) {
row.put(md.getColumnName(i), rs.getObject(i));
}
}
return row;
}
HttpRequest request = HttpRequest.post("http://site.ru/");
request.part("param1", "1");
request.part("param2", "xxx");
request.part("file", new File("/test.txt"));
int status = request.code();
if(status == 200) {
System.out.println(request.body());
}