get Value From ResultSet - Java java.sql

Java examples for java.sql:ResultSet

Description

get Value From ResultSet

Demo Code


//package com.java2s;
import java.sql.ResultSet;
import java.sql.SQLException;

public class Main {
    public static Object getValueFromRs(ResultSet rs, String columnName) {
        Object val = null;
        try {/*from   w  ww  . ja v a  2 s. co  m*/

            val = rs.getObject(columnName);
            if ("".equals(val)) {
                val = null;
            }
        }

        catch (SQLException sqle) {
            val = null;
        }
        return val;
    }
}

Related Tutorials