NutzCN Logo
问答 这个怎解决呢 我知道是类型无法转换
发布于 2473天前 作者 qq_5b5b952f 1625 次浏览 复制 上一个帖子 下一个帖子
标签:

org.nutz.dao.util.blob.SimpleBlob cannot be cast to oracle.sql.BLOB

 oracle.sql.BLOB blob =(BLOB) s.getZp();
                   OutputStream outStream = blob.getBinaryOutputStream();
                   File file = new File(urlpath);
                   InputStream fin = new FileInputStream(file);
                   byte[] b = new byte[1024];
                   int len = 0;
                   while ((len = fin.read(b)) != -1) {
                       outStream.write(b, 0, len);
                   }
                   outStream.flush();
                   outStream.close();
                   fin.close();
                   file.delete();
3 回复

因为实际类型就是 org.nutz.dao.util.blob.SimpleBlob, 并非你以为的 oracle.sql.BLOB

 java.sql.Blob blob = (java.sql.Blob)s.getZp();
Files.write(urlpath, blob.getBinaryOutputStream());

貌似不行啊 他会报这个错误
The method getBinaryOutputStream() is undefined for the type Blob
只有改成 这样blob.getBinaryStream())才行

getBinaryStream是对的, 我写的getBinaryOutputStream是错的

添加回复
请先登陆
回到顶部