public int executeUpdate(String sql) throws SQLException{ if (con == null con.isClosed()) makeConnection(); Statement stmt = con.createStatement(); //这个stmt在执行更新操作时更加节省内存,永远记住,能节省的时候要节省每一个字节的内存,虽然硬件设备可能会有很大的物理内存,但内存是给用户用的而不是给程序员用的(!!!!!!!!!!!!!!!!!!) int s = stmt.executeUpdate(sql); return s; }
//以上实现了常用功能,还有两个通用的功能也是/"共性/"的,我们一起在这个封装类中实现: 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; } }