0 Replies Latest reply on Oct 27, 2004 4:47 PM by robinbajaj

    CachedRowSet.getBlob() throws Datatype mismatch while retrie

    robinbajaj


      My Servlet code is using a CachedRowSet to get a blob datatype from mySQL4 database using getBlob() function,from the table
      uploads(uploadid int(10),filename varchar(20),BINARYFILE BLOB);

      using the following code.

      CachedRowSet rs;
      rs =new CachedRowSetImpl();
      rs.setCommand("SELECT * FROM uploads2");
      rs.execute(con);

      while(rs.next()){
      System.out.println("hi there");
      String s=rs.getString("filename"); //executes successfully

      java.sql.Blob image=
      rs.getBlob("BINARYFILE");
      //throws exception
      }
      catch(java.sql.SQLException s){
      System.out.println("SQLException:"+s.getMessage);
      }

      ---------jboss output console----------------
      12:04:15,942 INFO [STDOUT] hi there
      12:04:15,942 INFO [STDOUT] Type is :-4
      12:04:15,942 INFO [STDOUT] SQLException: Data Type Mismatch
      12:04:15,942 INFO [STDOUT] java.sql.SQLException: Data Type Mismatch
      12:04:15,942 INFO [STDOUT] at com.sun.rowset.CachedRowSetImpl.getBlob(Unknown Source)
      12:04:15,942 INFO [STDOUT] at com.sun.rowset.CachedRowSetImpl.getBlob(Unknown Source)
      12:04:15,942 INFO [STDOUT] at dev.servlets.AccessTimerServlet.doPost(AccessTimerServlet.java:85)

      ---------------------------
      kindly help me .
      If I use simple ResultSet instead of CachedRowSet ,
      then though it works but then ResultSets are not Serializable.(i.e the only reason i want to use CachedRowSet
      beacuase they are Serializable)

      Please help.

      regards
      robin
      ----------------------------------------------