首页上一页 1 下一页尾页 2 条记录 1/1页
着急高手快来帮我
发表在JavaWeb图书答疑
2010-03-23
是否精华
是
否
版块置顶:
是
否
private DBBean db;
public boolean insert(wenzhangBean wb)
{
db=DBBean.getInstance();
ResultSet rs = null;
String sql="insert into wenzhang5 values('"+wb.getId()+"','"+wb.getTitle()+"','"+wb.getName()+"','"+wb.getJibie()+"','"+wb.getTimes()+"',EMPTY_BLOB())";
String sql1="select content from wenzhang5 where id='"+wb.getId()+"' for update";
boolean b=false;
try {
b=db.execute(sql);
rs=db.getResults(sql1);
while(rs.next())
{
BLOB b1 = (BLOB)rs.getBlob("content");
File file = new File("E://xieru.txt");
file.createNewFile();
FileInputStream fin = new FileInputStream(file);
System.out.println("eeeeeeeeeeeeeeeeeeeee"+fin.toString()+"eeeeeeeeeeeeeeeeeeeeee");
System.out.print("aaaaaaaaaaaaaaaaaa"+wb.getContent()+"aaaaaaaaaaaaaaaaaa");
OutputStream out = b1.setBinaryStream(0);
byte[] data = new byte[b1.getBufferSize()];
int count = -1, total = 0;
while ((count = fin.read(data)) != -1) {
total += count;
out.write(data, 0, count);
}
String updateBin = "update wenzhang5 set content='"+b1+"' where id='"+wb.getId()+"'";
b= db.execute(updateBin);
fin.close();
out.close();
}
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
finally
{
db.closeAll();
}
return b;
}
public boolean insert(wenzhangBean wb)
{
db=DBBean.getInstance();
ResultSet rs = null;
String sql="insert into wenzhang5 values('"+wb.getId()+"','"+wb.getTitle()+"','"+wb.getName()+"','"+wb.getJibie()+"','"+wb.getTimes()+"',EMPTY_BLOB())";
String sql1="select content from wenzhang5 where id='"+wb.getId()+"' for update";
boolean b=false;
try {
b=db.execute(sql);
rs=db.getResults(sql1);
while(rs.next())
{
BLOB b1 = (BLOB)rs.getBlob("content");
File file = new File("E://xieru.txt");
file.createNewFile();
FileInputStream fin = new FileInputStream(file);
System.out.println("eeeeeeeeeeeeeeeeeeeee"+fin.toString()+"eeeeeeeeeeeeeeeeeeeeee");
System.out.print("aaaaaaaaaaaaaaaaaa"+wb.getContent()+"aaaaaaaaaaaaaaaaaa");
OutputStream out = b1.setBinaryStream(0);
byte[] data = new byte[b1.getBufferSize()];
int count = -1, total = 0;
while ((count = fin.read(data)) != -1) {
total += count;
out.write(data, 0, count);
}
String updateBin = "update wenzhang5 set content='"+b1+"' where id='"+wb.getId()+"'";
b= db.execute(updateBin);
fin.close();
out.close();
}
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
finally
{
db.closeAll();
}
return b;
}