@Override public ArrayList<ArrayList<String>> getSQLQueryDataForLimitedRows(DBType dbType, String hostname, int portnumber, String username, String password, String query, String dBorSIDName, int rowCount) throws SQLException, ClassNotFoundException { String connectString = getConnectString(hostname, portnumber, username, password, dBorSIDName); Connection conn = getConnection(DRIVER, connectString); Statement s = conn.createStatement(); if(query.toLowerCase().indexOf(" where rownum") == -1) //Add limit only if it doesnt exist, else sql will be invalid query = query + " where rownum < " + rowCount; logger.info("Execute:" + query); ResultSet r = s.executeQuery(query); if (r == null) { s.close(); return null; } ArrayList<ArrayList<String>> vals = parseResultSetIntoArrayListOfRows(r); r.close(); s.close(); return vals; }
@Override public ArrayList<ArrayList<String>> getDataForLimitedRows(DBType dbType, String hostname, int portnumber, String username, String password, String tableName, String dBorSIDName, int rowCount) throws SQLException, ClassNotFoundException { String connectString = getConnectString(hostname, portnumber, username, password, dBorSIDName); Connection conn = getConnection(DRIVER, connectString); Statement s = conn.createStatement(); String query = "select * from " + escapeTablename(tableName) + " where rownum < " + rowCount; logger.info("Execute:" + query); ResultSet r = s.executeQuery(query); if (r == null) { s.close(); return null; } ArrayList<ArrayList<String>> vals = parseResultSetIntoArrayListOfRows(r); r.close(); s.close(); return vals; }