How to list all tables, columns, and column types of an Entity Relationship Diagram

I am trying to develop a VP plugin:

  • I have draw a "Entity Relationship Diagram "wich contains some tables like Customers and Employees…
  • I have read some tutorial about developing plugin but I cannot find a solution for my problem.

My problem is that for my plugin I need to list the tables, their columns and the type of the columns. Here my code:

      Iterator modelElementIterator = project.modelElementIterator("DBTable");
      IDBTable dbTable = null; 
      IDBColumn dbColumn = null; 
     viewManager.showMessage("Utilitaire de génération de fichier .vb à partir du modèle MCD");
     IModelElement[] dbTables = project.toModelElementArray("DBTable"); 
     for(int i = 0; i <= dbTables.length; i++){
    // IModelElement otherModel = (IModelElement) tablesAtRoot[j]; 
         Object object = dbTables[i]; 
         if(object instanceof IDBTable){
             dbTable = (IDBTable) object;  
             viewManager.showMessage("Table name is : " + dbTable.getName());
             IDBColumn[] columns = dbTable.toDBColumnArray() ;
             for(int k = 0; k <= columns.length ; k++){
                 Object object2 = columns[k];
                 if(object2 instanceof IDBColumn){
                     dbColumn = (IDBColumn) object2;
                     viewManager.showMessage("===> Column name is :  " + dbColumn.getName());
                     viewManager.showMessage("===> Column type is :  " + dbColumn.getModelType().toString()); 
                    // model type = DBColumn
                     // But I want to list the type of the column as "Varchar2, Int, Date...
                     // And after that I want to cast for example "Varchar2 to String"... 
                 }// End for1
     }// End for2

When executing this code the view manager on VP show me only the data for one Table:

Table name is : Clients
===> Column name is : Client_Id
===> Column type is : DBColumn
===> Column name is : Addresse
===> Column type is : DBColumn
===> Column name is : Registration_Date
===> Column type is : DBColumn

And executing the code whitout the “Colums” loop it list me all the table names, consequently I cannot see the error.
Can someone help me?

Thank you in advance