public int executeUpdate(String sql) throws SQLException{ if (con == null con.isClosed()) makeConnection(); Statement stmt = con.createStatement(); //這個stmt在執(zhí)行更新操作時更加節(jié)省內(nèi)存,永遠記住,能節(jié)省的時候要節(jié)省每一個字節(jié)的內(nèi)存,雖然硬件設(shè)備可能會有很大的物理內(nèi)存,但內(nèi)存是給用戶用的而不是給程序員用的(!!!!!!!!!!!!!!!!!!) int s = stmt.executeUpdate(sql); return s; }
//以上實現(xiàn)了常用功能,還有兩個通用的功能也是/"共性/"的,我們一起在這個封裝類中實現(xiàn): public PreparedStatement getPreparedStmt(String sql) throws SQLException{ if (con == null con.isClosed()) makeConnection(); PreparedStatement ps = con.prepareStatement(sql); return ps; } public CallableStatement getCallableStmt(String sql) throws SQLException{ if (con == null con.isClosed()) makeConnection(); PreparedStatement ps = con.prepareCall(sql); return ps; }
public class OracleDBOperater extends DBOperater{ public OracleXMLQuery getOXQuery(String sql,String table) throws Exception { OracleXMLQuery qry = new OracleXMLQuery(con,sql); qry.setRowsetTag(table); qry.setRowTag(/"RECORD/"); return qry; } public int insertXML(String path,String table) throws Exception { OracleXMLSave sav = new OracleXMLSave(con,table); URL url = sav.createURL(path); sav.setRowTag(/"RECORD/"); int x = sav.insertXML(url); sav.close(); return x; } }