Code example for ResultSetMetaData

Methods: getColumnCount

0
         throw new IllegalStateException( "Not Connected to Database" );
 
      // determine number of columns 
      try  
      { 
         return metaData.getColumnCount(); 
      } // end try 
      catch ( SQLException sqlException ) 
      { 
         sqlException.printStackTrace();
      } // end catch 
       
      return 0; // if problems occur above, return 0 for number of columns 
   } // end method getColumnCount 
 
   // get name of a particular column in ResultSet 
   public String getColumnName( int column ) throws IllegalStateException
   {     
      // ensure database connection is available 
      if ( !connectedToDatabase ) 
         throw new IllegalStateException( "Not Connected to Database" );