Java SQL ResultSet to toSingleResult(ResultSet rs)

Here you can find the source of toSingleResult(ResultSet rs)

Description

to Single Result

License

Apache License

Declaration

public static Object toSingleResult(ResultSet rs) 

Method Source Code

//package com.java2s;
//License from project: Apache License 

import java.sql.ResultSet;

public class Main {
    public static Object toSingleResult(ResultSet rs) {
        Object result = null;/*from w  ww.  jav a2s .  c o m*/
        try {
            while (rs.next()) {
                result = rs.getObject(1);
                break;
            }
        } catch (Exception e) {
            throw new RuntimeException(e.getMessage());
        }

        return result;
    }
}

Related

  1. toMap(final ResultSet resultSet)
  2. toMap(final ResultSet resultSet)
  3. toMapList(ResultSet rs)
  4. toMapOfLists(ResultSet rs)
  5. toObjectArray(ResultSet resultSet)