Hello
There is no error and no table. Could someone find the missing code needed to render the table?
How do I Verify that outocommit is OFF?
output:
in personalDataTable: Supports Scroll
headers: ADMIN_UID
headers: ADMIN_PASSWORD
headers: ADMIN_LNAME
headers: ADMIN_MNAME
headers: ADMIN_FNAME
headers: ADMIN_GENDER
headers: ADMIN_AGE
headers: ADMIN_START_DATE
headers: ADMIN_END_DATE
headers: ADMIN_ADDRESS
headers: ADMIN_STATE
headers: ADMIN_ZIP
headers: ADMIN_AREA_CODE
headers: ADMIN_PHONE
headers: ADMIN_PAY_RATE
records in: ag
records in: a
records in: null
records in: null
records in: Garth
records in: null
records in: null
records in: null
records in: null
records in: null
records in: null
records in: null
records in: null
records in: null
records in: null
innerclass: setQuery(): 15 Columns and 1 records
public void personalDataTable(String thisUser) throws FileNotFoundException,
IOException, SQLException {
cad = new ConnectAdminDAO();
setConn(cad.getConn());
//conn = getConn();
rs = cad.personalDataTable(thisUser);//send param to return the rs from query
rsmd = (ResultSetMetaData) rs.getMetaData();
//pct.printColTypes(rsmd);
model = new ResultSetTableModel();
model.setQuery(rs, rsmd);
table = new JTable(model);
table.setPreferredScrollableViewportSize(new Dimension(500, 70));
table.setFillsViewportHeight(true);
JScrollPane scrollpane = new JScrollPane(table);
scrollpane.setVisible(true);
tablePanel.add(scrollpane);
tablePanel.setBorder(BorderFactory.createLoweredBevelBorder());
add(tablePanel);
//rs.close();
}
public class ResultSetTableModel extends AbstractTableModel {
//public Vector cache; // will hold String[] objects . . .
public int columnCount;
public String[] headers;
public ResultSet rs;
public ResultSetMetaData rsmd;
private int c = 0;
public void setQuery(ResultSet rs, ResultSetMetaData rsmd) throws FileNotFoundException,
IOException, SQLException {
this.rs = rs;
this.rsmd = rsmd;
recordCount = 0;
////////////////////////// debug //////////////////////////////
try {
headers = new String[getColumnCount()];
for (int h = 1; h <= getColumnCount(); h++) {
headers[h - 1] = rsmd.getColumnName(h);
System.out.println("headers: " + rsmd.getColumnName(h));
}
while (rs.next()) {
record = new String[getColumnCount()];
for (int i = 0; i < getColumnCount(); i++) {
record[i] = rs.getString(i + 1);
System.out.println("records in: " + rs.getString(i + 1));
}
recordCount++;
}
////////////////////////// debug //////////////////////////////
fireTableChanged(null); // notify everyone that we have a new table.
System.out.println("innerclass: setQuery(): "
+ rsmd.getColumnCount() + " Columns and " + recordCount + " records");
} catch (Exception e) {
e.printStackTrace();
}
}
public int getRowCount() {
try {
rs.last();
return rs.getRow();
} catch (SQLException ex) {
Logger.getLogger(AdminPanel.class.getName()).log(Level.SEVERE, null, ex);
ex.printStackTrace();
return 0;
}
}
public String getColumnName(int columnIndex){
try {
return rsmd.getColumnName(columnIndex + 1);
} catch (SQLException ex) {
Logger.getLogger(AdminPanel.class.getName()).log(Level.SEVERE, null, ex);
ex.printStackTrace();
return "";
}
}
public int getColumnCount() {
try {
return rsmd.getColumnCount();
} catch (SQLException ex) {
Logger.getLogger(AdminPanel.class.getName()).log(Level.SEVERE, null, ex);
ex.printStackTrace();
return 0;
}
}
public Object getValueAt(int rowIndex, int columnIndex) {
try {
rs.absolute(rowIndex + 1);
return rs.getObject(columnIndex + 1);
} catch (SQLException ex) {
Logger.getLogger(AdminPanel.class.getName()).log(Level.SEVERE, null, ex);
ex.printStackTrace();
return "";
}
}
public Class getColumnClass(int columnIndex) {
return getValueAt(0, columnIndex).getClass();
}
}