ResultSet getBigDecimal Example

ResultSet Interface getBigDecimal example. This example shows you how to use getBigDecimal


ResultSet Interface getBigDecimal example. BigDecimal getBigDecimal(String columnLabel, int scale) throws SQLException Retrieves the value of the designated column in the current row of this ResultSet object as a java.math.BigDecimal in the Java programming language.

Here is the code
/*
 * @ # GetBigDecimal3.java
 * A class repersenting use to getBigDecimal method 
 * of ResultSet in java.sql package
 * version 01 July 2008
 * author Rose India 
 */

import java.math.*;
import java.sql.*;

public class GetBigDecimal3 {

  public static void main(String[] argsthrows Exception {
    Connection con = null;
    Statement st = null;
    ResultSet rs = null;

    BigDecimal bigDecimal = null;

    String driver = "com.mysql.jdbc.Driver";
    String url = "jdbc:mysql://192.168.10.59:3306/";
    String db = "Student";

    Class.forName(driver);
    con = DriverManager.getConnection(url + db, "root""root");

    try {
      String sql = "Select * from stu_info";

      st = con.createStatement();
      rs = st.executeQuery(sql);

      while (rs.next()) {
        bigDecimal = rs.getBigDecimal("id",2);
        System.out.println(bigDecimal);
      }
      rs.close();
      st.close();
      con.close();
    catch (Exception e) {
      System.out.println(e);
    }
  }
}

Output
100.00
102.00
103.00
109.00

Post Comment
Name:
E-mail:
Contact no :
Comments:
  Refresh Image
Verify Image:
 
 
Your Comment's
 
 
 

HOME | COPYRIGHT | CONTACT US