return stmt.executeUpdate(sql); } public int[] executeUpdateBatch(String[] sqls) throws SQLException { conn.setAutoCommit(false); stmt = conn.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE,ResultSet.CONCUR_UPDATABLE); try { for (int i = 0; i < sqls.length; i++) { stmt.addBatch(sqls[i]); } int[] updateCounts=stmt.executeBatch(); conn.commit(); conn.setAutoCommit(true); return updateCounts; } catch (SQLException e) { conn.rollback(); throw e; } } public PreparedStatement prepareStatement(String sql) throws SQLException { pstmt = conn.prepareStatement(sql); return pstmt; } public CallableStatement callableStatement(String sql) throws SQLException { cstmt = conn.prepareCall(sql); return cstmt; }
public void setAutoCommit(boolean s) throws SQLException { conn.setAutoCommit(s); }
public void commit() throws SQLException { conn.commit(); }
public void rollback() throws SQLException { conn.rollback(); } public void close() throws SQLException { if (stmt != null) { stmt.close(); stmt = null; } if (conn != null) { conn.close(); conn = null; } }}
<%@ page contentType="text/html; charset=gb2312" language="java" errorPage="errorinfo.jsp"%><html><html><head><meta http-equiv="Content-Type" content="text/html; charset=gb2312"><title>testOracle</title></head><body><jsp:useBean id="operatedb" scope="page" class="com.cwbnig.OperateDB"/><% Object[] obj=null; obj=operatedb.getColName("TBL_STRUCTS"); for(int temp=0;temp<obj.length;temp++) { out.println(obj[temp]); } out.println("<br>"); java.util.Vector v=operatedb.getDataFromOracle(1,10,"TBL_STRUCTS","SID","","desc"); java.util.Enumeration e=v.elements(); while(e.hasMoreElements()) { obj=(Object[])e.nextElement(); for(int i=0;i<obj.length;i++) { out.println(obj[i]); } out.print("<br>"); }%></table><br><a href="testOracle.do?forward=bdgk">testOracle.do?forward=bdgk</a> </body></html>
上一页 [1] [2]
Copyright @ 2007-2012 敏韬网(敏而好学,文韬武略--MinTao.Net)(学习笔记) Inc All Rights Reserved. 闵涛 E_mail:admin@mintao.net(欢迎提供学习资源)
鄂公网安备 42011102001154号
站长:MinTao ICP备案号:鄂ICP备11006601号-18