Here you can find the source of extractIntResult(ResultSet rs, ResultSetMetaData rsmd, int index)
Parameter | Description |
---|---|
stmt | Statement that has been successfully executed |
index | Index of expected column |
Parameter | Description |
---|---|
Exception | If there is no column at index |
static public int extractIntResult(ResultSet rs, ResultSetMetaData rsmd, int index) throws Exception
//package com.java2s; import java.sql.ResultSet; import java.sql.ResultSetMetaData; public class Main { /**//from w w w .j a v a 2 s .c om * This method returns an int result at a given index. * @param stmt Statement that has been successfully executed * @param index Index of expected column * @return A value returned at the specified index * @throws Exception If there is no column at index */ static public int extractIntResult(ResultSet rs, ResultSetMetaData rsmd, int index) throws Exception { int count = rsmd.getColumnCount(); if (index > count || index < 1) { throw new Exception("Invalid index"); } int type = rsmd.getColumnType(index); switch (type) { case java.sql.Types.INTEGER: case java.sql.Types.SMALLINT: return rs.getInt(index); } throw new Exception("Column type (" + type + ") invalid for a string at index: " + index); } }