发布环境:jdk1.5,tomcat5.5.17,oralce9i
在存储图片的时候,代码如下:
String sqlB = "SELECT photo FROM tcard WHERE cardid=" + cardId +
                          " FOR UPDATE";
            pstmt1 = con.prepareStatement(sqlB);
            rs = pstmt1.executeQuery();
            BLOB blob = null; 
            while (rs.next()) {
                blob = (BLOB) rs.getBlob("photo");
                OutputStream out = blob.getBinaryOutputStream(); 
                // Open the sample file as a stream for insertion into the Blob column
                File mapFile = new File(bean.getPhoto());
                InputStream sampleFileStream = new FileInputStream(mapFile);
                // Buffer to hold chunks of data to being written to the Blob.
                byte[] buffer = new byte[50 * 1024];
                // Read a chunk of data from the sample file input stream, and write the
                // chunk to the Blob column output stream. Repeat till file has been
                // fully read.
                int nread = 0; // Number of bytes read
                while ((nread = sampleFileStream.read(buffer)) != -1) // Read from file
                    out.write(buffer, 0, nread); // Write to Blob
                // Close both streams
                sampleFileStream.close();
                out.close();
            }但是报错提示是:java.lang.ClassCastException:oralce.sql.BLOB