Java Reference
In-Depth Information
ResultSet rs = stmt.executeQuery(SQLQuery);
ResultSetMetaData md = rs.getMetaData();
int nColumns = md.getColumnCount();
while(rs.next()){
Vector rowData = new Vector();
for(int i=1;i<=nColumns;i++){
rowData.addElement(rs.getObject(i));
}
dataSet.addElement(rowData);
}
con.close();
}
catch(SQLException e){
reportException(e.getMessage());
}
return dataSet;
}
public void setExceptionListener(ActionListener exceptionListener){
this.exceptionListener=exceptionListener;
}
private void reportException(String exception){
if(exceptionListener!=null){
ActionEvent evt = new ActionEvent(this,0,exception);
exceptionListener.actionPerformed(evt);
}else{
System.err.println(exception);
}
}
}
Summary
In this chapter you learned how to build and use queries and subqueries. You also learned how to use
queries and subqueries in a SELECT command as well as in the INSERT, DELETE , and UPDATE
commands. Other topics discussed were:
 
What a Query is and how to create and execute one
Search WWH ::




Custom Search