Code example for ResultSet

Methods: getBlob, getString, isLast, next

0
  public Blob selectBlob (Connection con, int key ) throws Exception {
    PreparedStatement stmt = con.prepareStatement("SELECT value,key FROM blobtest where key = ?");
    stmt.setInt(1, key);
    ResultSet rs = stmt.executeQuery();
    assertTrue ("Executed", rs != null);
    rs.next();
    System.err.println ("blob record \"" + rs.getBlob(1).toString() + "\" key " + rs.getString(2) );
    assertTrue (" Only one record ", rs.isLast());
    Blob b = rs.getBlob(1);
    return b;
  } 
 
  /** Test the serialization of the various value objects. */ 
  public void testBlob () throws Exception { 
 
    DriverManager.registerDriver((Driver)(Class.forName(driverName, true, getClass().getClassLoader()).newInstance()));
 
    File f = new File("blobtest");
    if ( f.exists() ) {
      f.delete();
    }