List of usage examples for javax.sql.rowset CachedRowSet getDouble
double getDouble(int columnIndex) throws SQLException;
ResultSet
object as a double
in the Java programming language. From source file:CachedRS.java
public static void main(String[] args) throws Exception { FileInputStream fis = new FileInputStream(CRS_FILE_LOC); ObjectInputStream in = new ObjectInputStream(fis); CachedRowSet crs = (CachedRowSet) in.readObject(); fis.close();/* w w w . j a va 2 s . com*/ in.close(); Class.forName("oracle.jdbc.driver.OracleDriver"); crs.setUrl("jdbc:oracle:thin:@localhost:1521:ORCL"); crs.setUsername("yourName"); crs.setPassword("mypwd"); String sql = "SELECT SSN, Name, Salary, Hiredate FROM Employees WHERE SSN=?"; crs.setCommand(sql); crs.setInt(1, 111111111); crs.execute(); FileOutputStream fos = new FileOutputStream(CRS_FILE_LOC); ObjectOutputStream out = new ObjectOutputStream(fos); out.writeObject(crs); out.close(); crs.close(); fis = new FileInputStream(CRS_FILE_LOC); in = new ObjectInputStream(fis); crs = (CachedRowSet) in.readObject(); fis.close(); in.close(); while (crs.next()) { System.out.print("SSN: " + crs.getInt("ssn")); System.out.print(", Name: " + crs.getString("name")); System.out.print(", Salary: $" + crs.getDouble("salary")); System.out.print(", HireDate: " + crs.getDate("hiredate")); } crs.close(); }