Hi, I ave a poroblem and could not find a solution on the internet yet.

I am using JDBC to get data from an access database. I use resultset and read funciton (that I got from internet) to view displayed results.

What I want to do is, see some columns not wide, and some columns wider.

For example, ID columsn which shows 2 digit numbers, should not be wide as others columns, and Address column should be wide.

Here is the code that shows resultset on the screen. Please Help

private void displayResultSet( ResultSet rs ) throws SQLException
{
// position to first record
boolean moreRecords = rs.next();

// If there are no records, display a message
if ( !moreRecords ) {
JOptionPane.showMessageDialog( this,
"ResultSet contained no records" );
setTitle( "No records to display" );
return;
}

Vector columnHeads = new Vector();
Vector rows = new Vector();

try {
// get column heads
ResultSetMetaData rsmd = rs.getMetaData();

for ( int i = 1; i <= rsmd.getColumnCount(); ++i )
columnHeads.addElement( rsmd.getColumnName( i ) );

// get row data
do {
rows.addElement( getNextRow( rs, rsmd ) );
} while ( rs.next() );

// display table with ResultSet contents
table = new JTable( rows, columnHeads );
JScrollPane scroller = new JScrollPane( table );
Container c = getContentPane();
c.remove( 1 );
c.add( scroller, BorderLayout.CENTER );
c.validate();

} // end try

catch ( SQLException sqlex ) {
sqlex.printStackTrace();
}

} // end method displayResultSet

private Vector getNextRow( ResultSet rs,
ResultSetMetaData rsmd ) throws SQLException
{
Vector currentRow = new Vector();

for ( int i = 1; i <= rsmd.getColumnCount(); ++i )
switch( rsmd.getColumnType( i ) ) {
case Types.VARCHAR:
case Types.LONGVARCHAR:
currentRow.addElement( rs.getString( i ) );
break;
case Types.INTEGER:
currentRow.addElement( new Long( rs.getLong( i ) ) );
break;
case Types.REAL:
currentRow.addElement( new Float( rs.getDouble( i ) ) );
break;
case Types.DATE:
currentRow.addElement( rs.getDate( i ) );
break;
default:
System.out.println( "Type was: " +
rsmd.getColumnTypeName( i ) );
}

return currentRow;

} // end method getNextRow