Here you can find the source of lookupColumnIndex(final ResultSetMetaData resultSetMetaData, final String columnName)
public static int lookupColumnIndex(final ResultSetMetaData resultSetMetaData, final String columnName) throws SQLException
//package com.java2s; /**// ww w . j av a2s.c o m * Licensed under the Apache License, Version 2.0 * * @author ??(cknet@126.com, 13910090885) * https://github.com/simpleframework * http://www.simpleframework.net */ import java.sql.ResultSetMetaData; import java.sql.SQLException; public class Main { public static int lookupColumnIndex(final ResultSetMetaData resultSetMetaData, final String columnName) throws SQLException { if (columnName != null) { for (int i = 1; i <= resultSetMetaData.getColumnCount(); i++) { if (columnName.equalsIgnoreCase(lookupColumnName(resultSetMetaData, i))) { return i; } } } return 0; } public static String lookupColumnName(final ResultSetMetaData resultSetMetaData, final int columnIndex) throws SQLException { String name = resultSetMetaData.getColumnLabel(columnIndex); if (name == null || name.length() < 1) { name = resultSetMetaData.getColumnName(columnIndex); } return name; } }