; catch (SQLException e) { System.out.print("SQL Exception occur. Message is:"); System.out.print(e.getMessage()); } } // perform a query with records returned public ResultSet executeQuery(String sql) throws SQLException { ResultSet rs = null; try { stmt = con.createStatement(); rs = stmt.executeQuery(sql); while(rs.next()) this.rows ++; rs = stmt.executeQuery(sql); } catch (SQLException e) { System.out.print("Query:"+e.getMessage()); } this.rs = rs; return rs; }
// perform a query without records returned public boolean executeUpdate(String sql) { try { stmt = con.createStatement(); stmt.executeUpdate(sql); return true; } catch(SQLException e) { System.out.print("Update:"+e.getMessage()); return false; } }
// return the num of columns public int getColumns() { int columns = 0; try { this.resultsMeta = this.rs.getMetaData(); columns = this.resultsMeta.getColumnCount(); } catch (SQLException e) {} return columns; }
// return the num of rows public int getRows() { return this.rows; }
public String getDBName() { return this.dbName; }
}
上一页 [1] [2] |