public void insertNewCurrency_Rate(Rate_setInfo info)throws RemoteException{ Connection con = null;PreparedStatement ps = null;StringBuffer strBuff = new StringBuffer();//try{con = Database.getConnection();//启动数据库 //下一行链接数据库表String control=" insert into currency_set(tseffectivedate,sbasecurrency,scurrencyunit,sinputusername,tsinputdate,lcurrencyrate,scurrency)values('"+info.getTsEffectiveDate()+"','"+info.getSBaseCurrency()+"','"+info.getSCurrencyUnit()+"','"+info.getSInputUsername()+"','"+info.getTsInputDate()+"','"+info.getLCurrencyRate()+"','"+info.getSCurrency()+"'";ps = con.prepareStatement(control.toString());ps.executeUpdate();//关闭资源ps.close();ps = null;con.close();con = null;}catch (Exception e){e.printStackTrace();throw new RemoteException(e.getMessage());}finally{try{if (ps != null)ps.close();if (con != null)con.close();}catch (Exception ex){throw new RemoteException(ex.getMessage());}}}
1 回答
陪伴而非守候
TA贡献1757条经验 获得超8个赞
将“//关闭资源
ps.close();
ps = null;
con.close();
con=null;“ 去掉
finally里,ps和con各使用一个try与catch,不要搞到一起。
添加回答
举报
0/150
提交
取消