java/jdbc-loopback-driver/src/main/java/info/globalcode/jdbc/loopback/ResultSetMetaData.java
3 * Copyright © 2014 František Kučera (frantovo.cz)
5 * This program is free software: you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation, version 3 of the License.
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License
15 * along with this program. If not, see <http://www.gnu.org/licenses/>.
17 package info.globalcode.jdbc.loopback;
19 import java.sql.SQLException;
20 import java.util.ArrayList;
21 import java.util.List;
25 * @author Ing. František Kučera (frantovo.cz)
27 public class ResultSetMetaData extends AbstractResultSetMetaData {
29 private List<ColumnDescriptor> columns = new ArrayList<>();
31 public void addColumn(ColumnDescriptor cd) {
36 public int getColumnCount() throws SQLException {
37 return columns.size();
41 public String getColumnLabel(int column) throws SQLException {
42 return columns.get(column - 1).label;
46 public String getColumnName(int column) throws SQLException {
47 return columns.get(column - 1).name;
51 public int getColumnType(int column) throws SQLException {
52 return columns.get(column - 1).type;
56 public String getColumnTypeName(int column) throws SQLException {
57 return columns.get(column - 1).typeName;
60 public static class ColumnDescriptor {
62 private final int type;
63 private final String typeName;
64 private final String label;
65 private final String name;
67 public ColumnDescriptor(int type, String typeName, String label, String name) {
69 this.typeName = typeName;