Here you can find the source of getColumnType(ResultSetMetaData rsm)
Parameter | Description |
---|---|
rsm | a parameter |
Parameter | Description |
---|---|
SQLException | an exception |
public static Map<Integer, Integer> getColumnType(ResultSetMetaData rsm) throws SQLException
//package com.java2s; /******************************************************************************* * Copyright (c) 2013 hangum.//from ww w. ja v a 2 s .co m * All rights reserved. This program and the accompanying materials * are made available under the terms of the GNU Lesser Public License v2.1 * which accompanies this distribution, and is available at * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html * * Contributors: * hangum - initial API and implementation ******************************************************************************/ import java.sql.ResultSetMetaData; import java.sql.SQLException; import java.util.HashMap; import java.util.Map; public class Main { /** * get column type * * @param rsm * @return * @throws SQLException */ public static Map<Integer, Integer> getColumnType(ResultSetMetaData rsm) throws SQLException { return getColumnType(false, rsm); } public static Map<Integer, Integer> getColumnType(boolean isShowRowNum, ResultSetMetaData rsm) throws SQLException { Map<Integer, Integer> mapColumnType = new HashMap<Integer, Integer>(); int intStartIndex = 0; if (isShowRowNum) { intStartIndex++; mapColumnType.put(0, java.sql.Types.INTEGER); } for (int i = 0; i < rsm.getColumnCount(); i++) { // logger.debug("\t ==[column start]================================ ColumnName : " + rsm.getColumnName(i+1)); // logger.debug("\tColumnLabel : " + rsm.getColumnLabel(i+1)); // logger.debug("\t AutoIncrement : " + rsm.isAutoIncrement(i+1)); // logger.debug("\t Nullable : " + rsm.isNullable(i+1)); // logger.debug("\t CaseSensitive : " + rsm.isCaseSensitive(i+1)); // logger.debug("\t Currency : " + rsm.isCurrency(i+1)); // // logger.debug("\t DefinitelyWritable : " + rsm.isDefinitelyWritable(i+1)); // logger.debug("\t ReadOnly : " + rsm.isReadOnly(i+1)); // logger.debug("\t Searchable : " + rsm.isSearchable(i+1)); // logger.debug("\t Signed : " + rsm.isSigned(i+1)); //// logger.debug("\t Currency : " + rsm.isWrapperFor(i+1)); // logger.debug("\t Writable : " + rsm.isWritable(i+1)); // // logger.debug("\t ColumnClassName : " + rsm.getColumnClassName(i+1)); // logger.debug("\t CatalogName : " + rsm.getCatalogName(i+1)); // logger.debug("\t ColumnDisplaySize : " + rsm.getColumnDisplaySize(i+1)); // logger.debug("\t ColumnType : " + rsm.getColumnType(i+1)); // logger.debug("\t ColumnTypeName : " + rsm.getColumnTypeName(i+1)); mapColumnType.put(i + intStartIndex, rsm.getColumnType(i + 1)); // logger.debug("\t Precision : " + rsm.getPrecision(i+1)); // logger.debug("\t Scale : " + rsm.getScale(i+1)); // logger.debug("\t SchemaName : " + rsm.getSchemaName(i+1)); // logger.debug("\t TableName : " + rsm.getTableName(i+1)); // logger.debug("\t ==[column end]================================ ColumnName : " + rsm.getColumnName(i+1)); } return mapColumnType; } }