Java Reference
In-Depth Information
for(int i=0;i<records.length;i++){
records[i]=(String[])dataSet.elementAt(i);
}
return records;
}
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);
}
}
public static void main(String args[]){
DataRetriever retriever = new DataRetriever();
retriever.setDatabaseName("Contacts");
String[][] records =
retriever.executeQuery("SELECT * FROM Contact_Info");
for(int i=0;i<records.length;i++){
String[] record = records[i];
for(int j=0;j<record.length;j++){
if(j>0)System.out.print("\t");
System.out.print(record[j]);
}
System.out.println();
}
}
}
The main difference between the code required to retrieve data from the table and the code you used
to insert it is the use of the ResultSet and ResultSetMetaData objects. The other difference is
Search WWH ::




Custom Search