public void executeQuery(String strSQL){
int i,max;
Vector rowData;
try
{
data = new Vector();
names = new Vector();
resultSet = statement.executeQuery(strSQL);
metaData = resultSet.getMetaData();
max = metaData.getColumnCount();
//get the column names
for(i=0;i< max;i++){
//adjust for meta data index start at 1
names.addElement(metaData.getColumnLabel(i+1));
}
//load the data
while (resultSet.next())
{
rowData = new Vector();
for (i=0;i< max;i++)
{
rowData.addElement(resultSet.getObject(i+1));
}
data.addElement(rowData);
}
fireTableChanged(null);
}
catch (Exception exp)
{
System.out.println("Error performing query: " + exp);
System.out.println(strSQL);
exp.printStackTrace();
}
}1
It is most likely that the user would have manually resized the columns when viewing the previous ResultSet in the table. How do i keep the column widths as was before the above method was called?
Thanks

New Topic/Question
Reply



MultiQuote




|