List of usage examples for javax.sql RowSet getString
String getString(int columnIndex) throws SQLException;
ResultSet
object as a String
in the Java programming language. From source file:Main.java
static void displayRowSet(RowSet rs) throws SQLException { while (rs.next()) { System.out.println(rs.getRow() + " - " + rs.getString("col1") + ":" + rs.getInt("col2") + ":" + rs.getString("col3")); }/*w w w . j a v a2s .co m*/ }
From source file:com.oracle.tutorial.jdbc.JdbcRowSetSample.java
private void outputRowSet(RowSet rs) throws SQLException { rs.beforeFirst();/*from w w w . j av a 2 s .c o m*/ while (rs.next()) { String coffeeName = rs.getString(1); int supplierID = rs.getInt(2); float price = rs.getFloat(3); int sales = rs.getInt(4); int total = rs.getInt(5); System.out.println(coffeeName + ", " + supplierID + ", " + price + ", " + sales + ", " + total); } }
From source file:ViewDB.java
/** * Updates changed data into the current row of the row set *///from ww w .j a v a 2s. co m public void setRow(RowSet rs) throws SQLException { for (int i = 1; i <= fields.size(); i++) { String field = rs.getString(i); JTextField tb = (JTextField) fields.get(i - 1); if (!field.equals(tb.getText())) rs.updateString(i, tb.getText()); } rs.updateRow(); }
From source file:org.aludratest.cloud.web.report.SqlBean.java
public synchronized void execute() { resultColumns = null;//from www .j av a 2 s .c o m resultRows = null; if (sql == null) { return; } sql = sql.trim(); while (sql.endsWith(";")) { sql = sql.substring(0, sql.length() - 1); } // easy basic check if (!sql.toLowerCase(Locale.US).startsWith("select ")) { FacesContext.getCurrentInstance().addMessage(null, JSFUtil.createErrorMessage("Only SELECT statements are allowed")); return; } try { RowSet rs = CloudManagerApplicationHolder.getInstance().getDatabase().populateQuery(sql); resultColumns = new ArrayList<String>(); ResultSetMetaData meta = rs.getMetaData(); for (int i = 1; i <= meta.getColumnCount(); i++) { resultColumns.add(meta.getColumnName(i)); } rs.beforeFirst(); resultRows = new ArrayList<Map<String, String>>(); while (rs.next()) { Map<String, String> row = new HashMap<String, String>(); // TODO nicer formatting etc. for (String col : resultColumns) { row.put(col, rs.getString(col)); } resultRows.add(row); } } catch (SQLException se) { FacesContext.getCurrentInstance().addMessage(null, JSFUtil.createErrorMessage("SQLException: " + se.getMessage())); } }