2 Replies Latest reply on Dec 6, 2008 2:46 PM by orkun

    problem with a4j:mediaOutput

    orkun

      hello


      I am trying to retrieve an image from database and display with "a4j:mediaOutput"

      here is the core of the code:

      Statement stmt = conn.createStatement();
      ResultSet rst = stmt.executeQuery("select * from fruit"); while(rst.next()) {
      byte[] imgBytes=new byte[(int) rst.getBytes(2).length];

      for (int i = 0; i < imgBytes.length - 1; i++) {

      imgBytes = rst.getByte(2);
      }
      output.write(imgBytes);
      }

      I get this exception :

      java.lang.ClassCastException: org.apache.tomcat.dbcp.dbcp.BasicDataSource cannot be cast to javax.activation.DataSource


      how may the solution be ?

      regards