代码如下,测试类里面测试好好的,但是放到程序里面就错了 哪位大大指点下啊
import java.io.FileOutputStream;
import java.io.InputStream;
import java.sql.ResultSet;import com.ac990.util.DbMainUtil;public class OLEDemo extends DbMainUtil{
public void blobRead(String outfile){
DbMainUtil dbUtil = new DbMainUtil();
try {
String strsql = "select * from tb201101_spda where f_bm = '001'" ;
ResultSet rs = dbUtil.query(strsql);
while (rs.next()) {
InputStream image = rs.getBinaryStream(24);
FileOutputStream file1 = null;
file1 = new FileOutputStream("d:/100.jpg");
int chunk;
while ((chunk = image.read()) != -1){
file1.write(chunk);
}
file1.flush();
file1.close();
}
} catch (Exception e) {
e.printStackTrace();
} finally {
dbUtil.cloes();
}
}
public static void main(String[] args) {
try {
OLEDemo gi=new OLEDemo();
} catch (Exception e) {
System.out.println("[Main func error: ]" + e.getMessage());
}
}}
import java.io.FileOutputStream;
import java.io.InputStream;
import java.sql.ResultSet;import com.ac990.util.DbMainUtil;public class OLEDemo extends DbMainUtil{
public void blobRead(String outfile){
DbMainUtil dbUtil = new DbMainUtil();
try {
String strsql = "select * from tb201101_spda where f_bm = '001'" ;
ResultSet rs = dbUtil.query(strsql);
while (rs.next()) {
InputStream image = rs.getBinaryStream(24);
FileOutputStream file1 = null;
file1 = new FileOutputStream("d:/100.jpg");
int chunk;
while ((chunk = image.read()) != -1){
file1.write(chunk);
}
file1.flush();
file1.close();
}
} catch (Exception e) {
e.printStackTrace();
} finally {
dbUtil.cloes();
}
}
public static void main(String[] args) {
try {
OLEDemo gi=new OLEDemo();
} catch (Exception e) {
System.out.println("[Main func error: ]" + e.getMessage());
}
}}
解决方案 »
- session 和 连接
- jsp:逐行删除每行对应的数据,为什么Servlet接不到值呢
- myeclipse9+struts-2.3.1.2+tomcat6.0做的第一个struts2
- 怎么在web根目录下写一个文件
- 高手请进,小弟有个难到好几个技术论坛的的简单问题
- Statement.execute()与executeQuery() executeUpdate()有什么联系和区别?
- 一个关于struts的问题!!!
- 求救!
- struts特殊字符过滤的问题
- 刷新网页 表单好像把空数据提交了怎么修改,谢谢
- java.sql.SQLException: Network error IOException: Address already in use: connect
- struts2自定义拦截器怎样传参数给action
哇塞 都叫大大了!都不知道你啥错误,我这个大大怎么找。
告诉我吧