ResultSet getBigDecimal Example
ResultSet Interface getBigDecimal example. This example shows you how to use getBigDecimal method.
ResultSet Interface getBigDecimal example. BigDecimal getBigDecimal(int columnIndex) throws SQLException Retrieves the value of the designated column in the current row of this ResultSet object as a java.math.BigDecimal with full precision.
Here is the code
/*
* @ # GetBigDecimal.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 GetBigDecimal {
public static void main(String[] args) throws 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(1);
System.out.println(bigDecimal);
}
rs.close();
st.close();
con.close();
} catch (Exception e) {
System.out.println(e);
}
}
} |
|