问个关于Blob的问题

changsir8 2012-04-10 09:49:45
public boolean excutesql(List<String> commonds , BigDecimal id , Blob blob0,Blob blob1) throws Exception{
this.dbconfig("D:\\workspace\\SMS_Project\\WebContent\\");
try {
Class.forName(Dirver);
}catch(Exception e){
System.out.println("驱动加载异常!");
return false;
}
Connection con = null;
try {
con=DriverManager.getConnection(Url, UserName,Password);
con.setAutoCommit(false);
for(int i=0;i<commonds.size();i++){
PreparedStatement stmt= null;
stmt = con.prepareStatement(commonds.get(i));
stmt.setBigDecimal(1, id);
stmt.setBlob(2, blob0);
stmt.setBlob(3, blob1);
stmt.executeUpdate();
stmt.close();
}
con.commit();
return true;
} catch (SQLException e) {
// TODO Auto-generated catch block
System.out.println("sql语句执行错误!");
e.printStackTrace();
try {
con.rollback();
} catch (SQLException e1) {
// TODO Auto-generated catch block
System.out.println("事务回滚异常!");
}
return false;
}finally{
try {
con.close();
} catch (SQLException e) {
// TODO Auto-generated catch block
System.out.println("事务关闭异常!");
}
}
}
=========================================================
public static void main(String[] args) throws Exception {
// TODO Auto-generated method stub
List<String>commonds = new ArrayList<String>();
commonds.add("insert into blobtest(id,pnumber,ecode,mtype,mesg,mtype2,mesg2) values(?,?,?,?,?,?,?)");
new test().excutesql(commonds, new BigDecimal(5),blob0 ,blob1);
//我想问的是这两个blob对象怎么搞呢?

}

...全文
84 2 打赏 收藏 转发到动态 举报
写回复
用AI写文章
2 条回复
切换为时间正序
请发表友善的回复…
发表回复
changsir8 2012-05-09
  • 打赏
  • 举报
回复
也没个人提供帮组,结贴吧
changsir8 2012-04-10
  • 打赏
  • 举报
回复
没人来吗?

51,409

社区成员

发帖
与我相关
我的任务
社区描述
Java相关技术讨论
javaspring bootspring cloud 技术论坛(原bbs)
社区管理员
  • Java相关社区
  • 小虚竹
  • 谙忆
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧