Topic: Applet下通过 prepareStatement 读SQL Server的Image字段内容时,为什么读不出来? |
Print this page |
1.Applet下通过 prepareStatement 读SQL Server的Image字段内容时,为什么读不出来? | Copy to clipboard |
Posted by: wgz_jz Posted on: 2004-11-29 14:05 在 Applet下 通过 prepareStatement 来读取SQL Server 中的Image字段内容时,为什么读不出来?InputStream.read总是返回 0,如果出错的话应该返回 -1;InputStream.available()为什么为0? 而同样的代码在 Application下却运行正常,这是为什么? 开发环境为: JBuilder X、JDBC for SQL Server(SP3) 部分具体代码如下: queryOnePicture = conn.prepareStatement("select 图 from 图表 where 图ID=?"); try { queryOnePicture.setInt(1,pictureID); ResultSet result = queryOnePicture.executeQuery(); try { result.next(); try { InputStream inputImage = null; inputImage = result.getBinaryStream(1); int lengthReaded=-1,positionCurrent=0; byte[] pictureBuffer = new byte[inputImage.available()+1]; do { lengthReaded = inputImage.read(pictureBuffer, positionCurrent, inputImage.available()); positionCurrent = positionCurrent + lengthReaded; } while (lengthReaded != -1); inputImage.close(); } catch (Exception e) { e.printStackTrace(); } } finally { result.close(); } } catch(Exception exception) { exception.printStackTrace(); } |
Powered by Jute Powerful Forum® Version Jute 1.5.6 Ent Copyright © 2002-2021 Cjsdn Team. All Righits Reserved. 闽ICP备05005120号-1 客服电话 18559299278 客服信箱 714923@qq.com 客服QQ 714923 |