Java: la Lecture de Blob Oracle

J'ai ce code qui convertit un Treemap en octets et de les stocker dans la base de données (Oracle 11g). Maintenant que le stockage semble fonctionner correctement. Je veux récupérer la carte maintenant, mais il est en octets dans le champ blob. Comment puis-je récupérer et re-construction de la carte?

Le code pour le stockage de la carte est:

 public void StoreMapDB(TreeMap<DateTime, Integer> map) throws
        IOException, FileNotFoundException{

       try {
          Connection con = null;

          Class.forName("oracle.jdbc.driver.OracleDriver");
          con=DriverManager.getConnection(
            "jdbc:oracle:thin:@dsds",
            "dsdsd",
            "XXdsdsX");
          con.setAutoCommit(false);
          ByteArrayOutputStream bos = new ByteArrayOutputStream() ;
          ObjectOutputStream out = new ObjectOutputStream(bos);
          out = new ObjectOutputStream(bos) ;
          out.writeObject(map);
          out.close();

          byte[] buf = bos.toByteArray();
          PreparedStatement prepareStatement = con.prepareStatement("INSERT INTO 
           SMD_DATESTREEMAP VALUES(?,?)");
          prepareStatement.setLong(1, 2);
          prepareStatement.setBinaryStream(2, new ByteArrayInputStream(buf),
           buf.length);
          prepareStatement.executeUpdate();


         //insertMap.executeUpdate();
          con.commit();
    } catch(Exception e){
        System.err.print(e);
    }
}

P. S. j'ai édité ce code, mais ne pense pas que cela fonctionne, car il affiche la taille de l'extrait de la carte à 0 là où il devrait être 366.

  public TreeMap<DateTime, Integer> retrieveMapDB()throws IOException,
        SQLException{

    try {
        Connection con = null;

        Class.forName("oracle.jdbc.driver.OracleDriver");
        con=DriverManager.getConnection(
            "jdbc:oracle:thin:@oradbfdfdt05:f:fdfd",
            "cxcx",
            "hpdbcxcxsmb");
        con.setAutoCommit(false);
        ResultSet rs = null;
        PreparedStatement pstmt = null;
        String query = "SELECT TREEMAP FROM SMD_DATESTREEMAP WHERE id = ?";
        try {
            pstmt = con.prepareStatement(query);
            int id = 1;
            pstmt.setInt(1, id);

            rs = pstmt.executeQuery();
            while(rs.next()){
                ByteArrayInputStream bos = new 
           ByteArrayInputStream(rs.getBytes("TREEMAP")) ;
                ObjectInputStream out = new ObjectInputStream(bos);
                retrievedmap=(TreeMap<DateTime, Integer>)out.readObject();
            }


        }catch(IOException ioe){
            System.err.print(ioe);
        }
    }catch(ClassNotFoundException cnfe){
        System.err.print(cnfe);
    }
  return retrievedmap;
}
InformationsquelleAutor sys_debug | 2011-12-09