存储sql2000特殊数据类型--image,text

存储image和text类型数据:

 

<%! public String getStr(String str){ try{ String temp=str; byte[] b=temp.getBytes("ISO8859-1");//由于网页默认以ISO8859-1编码,以ISO8859-1解码 return new String(b); }catch(Exception e){ return "null"; } } %> FileInputStream fis=new FileInputStream("fileURL");//fileURL为图片路径 PreparedStatement psmt=con.prepareStatement("insert into imageStore(photo,remark) values(?,?)"); int len=fis.available(); //得到图片字节长度 psmt.setBinaryStream(1,fis,len); context=getStr(context);//解码 psmt.setCharacterStream(2,new StringReader(context),context.length()); psmt.executeUpdate();

你可能感兴趣的:(sql,exception,String,image,存储,insert)