Here you can find the source of printQueryResults(List> res)
Parameter | Description |
---|---|
res | Query results. |
public static void printQueryResults(List<?> res)
//package com.java2s; /*//from ww w. j av a 2s .co m * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ import java.util.List; public class Main { /** * Convenience method for printing query results. * * @param res Query results. */ public static void printQueryResults(List<?> res) { if (res == null || res.isEmpty()) System.out.println("Query result set is empty."); else { for (Object row : res) { if (row instanceof List) { System.out.print("("); List<?> l = (List) row; for (int i = 0; i < l.size(); i++) { Object o = l.get(i); if (o instanceof Double || o instanceof Float) System.out.printf("%.2f", o); else System.out.print(l.get(i)); if (i + 1 != l.size()) System.out.print(','); } System.out.println(')'); } else System.out.println(" " + row); } } } }