Java SQL ResultSet hasGeometryField(ResultSet resultSet)

Here you can find the source of hasGeometryField(ResultSet resultSet)

Description

Check if the resultset contains a geometry field

License

Open Source License

Parameter

Parameter Description
resultSet a parameter

Exception

Parameter Description
SQLException an exception

Return

true if the resultset contains one geometry field

Declaration

public static boolean hasGeometryField(ResultSet resultSet)
        throws SQLException 

Method Source Code

//package com.java2s;
/*/*w w  w . j ava2 s.co m*/
 * h2spatial is a library that brings spatial support to the H2 Java database.
 *
 * h2spatial is distributed under GPL 3 license. It is produced by the "Atelier SIG"
 * team of the IRSTV Institute <http://www.irstv.fr/> CNRS FR 2488.
 *
 * Copyright (C) 2007-2014 IRSTV (FR CNRS 2488)
 *
 * h2patial is free software: you can redistribute it and/or modify it under the
 * terms of the GNU General Public License as published by the Free Software
 * Foundation, either version 3 of the License, or (at your option) any later
 * version.
 *
 * h2spatial is distributed in the hope that it will be useful, but WITHOUT ANY
 * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
 * A PARTICULAR PURPOSE. See the GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License along with
 * h2spatial. If not, see <http://www.gnu.org/licenses/>.
 *
 * For more information, please consult: <http://www.orbisgis.org/>
 * or contact directly:
 * info_at_ orbisgis.org
 */

import java.sql.ResultSet;
import java.sql.ResultSetMetaData;
import java.sql.SQLException;

public class Main {
    /**
     * Check if the resultset contains a geometry field
     *
     * @param resultSet
     * @return true if the resultset contains one geometry field
     * @throws SQLException
     */
    public static boolean hasGeometryField(ResultSet resultSet)
            throws SQLException {
        ResultSetMetaData meta = resultSet.getMetaData();
        int columnCount = meta.getColumnCount();
        for (int i = 1; i <= columnCount; i++) {
            if (meta.getColumnTypeName(i).equalsIgnoreCase("geometry")) {
                return true;
            }
        }
        return false;
    }
}

Related

  1. extractIntResult(ResultSet rs, ResultSetMetaData rsmd, int index)
  2. extractResults(ResultSet resultSet)
  3. extractResultSetFiledNames(ResultSet result)
  4. fillRowNames(Map metaData, ResultSet rs)
  5. hasCompleted(ResultSet rs)
  6. isNull(ResultSet rs, String name)
  7. isResultEmpty(ResultSet theResult)
  8. isReturnsInvalidResultSetException(SQLException se)
  9. isSupportedResultSetType(Connection connection, int resultSetType)