bsp; return obj; } public int getRowCount(String tablename) throws SQLException { stmt=conn.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE,ResultSet.CONCUR_READ_ONLY); strsql="SELECT COUNT(*) AS COUNT FROM "+tablename; rs=stmt.executeQuery(strsql); if(rs.next()) { return rs.getInt(1); } else { return 0; } } public int getRowCount(ResultSet rs) throws SQLException { int rowCount = 0; rs.last(); rowCount = rs.getRow(); rs.beforeFirst(); return rowCount; } public int executeUpdate(String sql) throws SQLException { stmt = conn.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE,ResultSet.CONCUR_UPDATABLE);
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] |