操作失误绝对不可以再次发生!20080818
自我介绍
切换风格
订阅我的Blog
博客日历
文章归档...
最新发表...
博客统计...
网站链接...
资源
===========================================================
access 取照片
===========================================================
public static void test_access_pic1(String table_id)throws SQLException{
Connection conn=null;
PreparedStatement stmt=null;
ResultSet rs=null;
int iiii=0;
String[] sql_field_str=null;
try {
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
String dburl ="jdbc:odbc:driver={Microsoft Access Driver (*.mdb)};DBQ=两口一屋.mdb";//此为NO-DSN方式
//String dburl ="jdbc:odbc:odbcName";//此为ODBC连接方式
conn=DriverManager.getConnection(dburl);
stmt=conn.prepareStatement("select pic from pic");

rs=stmt.executeQuery();

byte b[]=new byte[10240000];
FileOutputStream write=null;
while(rs.next()){
iiii+=1;
//System.out.println(rs.getString(2));
InputStream in=rs.getBinaryStream("pic");
File file=new File("c:imlihj00000@@@@@@@@@.jpg");
int len;
in.read(b);
write=new FileOutputStream(file);
write.write(b);

//问题的关键生成图片
//rs.close();
//stmt.close();
//conn.close();
} write.close();
}
catch (Exception ex) {
ex.printStackTrace();
}
finally{
// rs.close();
stmt.close();
conn.close();
}
}


imlihj2007 发表于:2008.02.29 10:48 ::分类: ( oracle ) ::阅读:(59次) :: Permanent link :: 引用 (0)