本文整理汇总了Java中java.sql.ResultSet.findColumn方法的典型用法代码示例。如果您正苦于以下问题:Java ResultSet.findColumn方法的具体用法?Java ResultSet.findColumn怎么用?Java ResultSet.findColumn使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类java.sql.ResultSet
的用法示例。
在下文中一共展示了ResultSet.findColumn方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: sortedCopy
import java.sql.ResultSet; //导入方法依赖的package包/类
/**
* Creates a copy of an {@link Iterable} of columns, where the copy is sorted such that the
* columns appear in the same order as they do in the supplied {@link ResultSet}.
*
* @param columns Columns expected.
* @param resultSet The result set containing the values.
* @return The sorted columns.
*/
public static Collection<Column> sortedCopy(Iterable<Column> columns, ResultSet resultSet) {
Column[] result = new Column[Iterables.size(columns)];
for (Column column : columns) {
try {
result[resultSet.findColumn(column.getName()) - 1] = column;
} catch(SQLException ex) {
throw new IllegalStateException("Could not retrieve column [" + column.getName() + "]", ex);
}
}
return Collections.unmodifiableCollection(Arrays.asList(result));
}
示例2: fillZChoice
import java.sql.ResultSet; //导入方法依赖的package包/类
private void fillZChoice(ZaurusChoice zc, String tab, String col) {
try {
if (cConn == null) {
return;
}
Statement stmt = cConn.createStatement();
ResultSet rs = stmt.executeQuery("SELECT * FROM " + tab
+ " ORDER BY " + col);
ResultSetMetaData rsmd = rs.getMetaData();
int numberOfColumns = rsmd.getColumnCount();
int colIndex = rs.findColumn(col);
while (rs.next()) {
String tmp = "";
for (int i = 1; i <= numberOfColumns; i++) {
if (i > 1) {
tmp += "; ";
}
tmp += rs.getString(i);
} // end of for (int i=1; i<=numberOfColumns; i++)
zc.add(tmp, rs.getString(colIndex));
}
rs.close();
} catch (SQLException e) {
System.out.println("SQL Exception: " + e.getMessage());
} // end of try-catch
}