get Single Result Double from PreparedStatement - Java java.sql

Java examples for java.sql:ResultSet

Description

get Single Result Double from PreparedStatement

Demo Code


//package com.java2s;

import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;

public class Main {
    public static Double getSingleResultDouble(PreparedStatement ps)
            throws SQLException {
        Double retval;/*from  ww  w.  j  a  v a  2 s.  co m*/
        ResultSet rs = ps.executeQuery();
        if (rs.next())
            retval = rs.getDouble(1);
        else
            retval = null;
        rs.close();
        return retval;
    }
}

Related Tutorials