Coverage Report - net.sourceforge.addam.util.DatabaseMetaDataUtil
 
Classes in this File Line Coverage Branch Coverage Complexity
DatabaseMetaDataUtil
0%
0/15
0%
0/7
0
 
 1  
 package net.sourceforge.addam.util;
 2  
 
 3  
 
 4  
 import java.util.List;
 5  
 import java.util.ArrayList;
 6  
 import java.sql.Connection;
 7  
 import java.sql.DatabaseMetaData;
 8  
 import java.sql.ResultSet;
 9  
 import java.sql.SQLException;
 10  
 
 11  
 import net.sourceforge.addam.ddlgen.GeneratorSpec;
 12  
 
 13  
 /**
 14  
  * Created by IntelliJ IDEA.
 15  
  * User: TIM3
 16  
  * Date: Oct 27, 2006
 17  
  * Time: 11:59:34 PM
 18  
  * To change this template use File | Settings | File Templates.
 19  
  */
 20  0
 public class DatabaseMetaDataUtil {
 21  
 
 22  
     public static List<String> getTables(String catalog, String schema, Connection connection) throws SQLException {
 23  
 
 24  0
         DatabaseMetaData metadata = connection.getMetaData();
 25  0
         if (metadata.storesUpperCaseIdentifiers()) {
 26  0
             catalog = (catalog == null) ? null : catalog.toUpperCase();
 27  0
             schema = (schema == null) ? null : schema.toUpperCase();
 28  0
         } else if (metadata.storesLowerCaseIdentifiers()) {
 29  0
             catalog = (catalog == null) ? null : catalog.toLowerCase();
 30  0
             schema = (schema == null) ? null : schema.toLowerCase();
 31  
         }
 32  0
         ResultSet tablesRS = metadata.getTables(catalog, schema, "%", new String[]{"TABLE"});
 33  0
         List<String> objects = new ArrayList<String>();
 34  0
         while (tablesRS.next()) {
 35  0
             String dbObject = tablesRS.getString(3);
 36  0
             objects.add(dbObject);
 37  0
         }
 38  0
         return objects;
 39  
     }
 40  
 
 41  
 }