package net.sourceforge.phpdt.sql.adapters; import java.sql.Connection; import java.sql.DatabaseMetaData; import java.sql.ResultSet; import java.sql.SQLException; import java.util.ArrayList; import java.util.List; import net.sourceforge.phpdt.sql.bookmarks.Bookmark; import net.sourceforge.phpdt.sql.model.Entity; import net.sourceforge.phpdt.sql.model.EntityFactory; public class GenericAdapter extends DatabaseAdapter { public String getShowTableQuery(DatabaseInfo info) { return null; } public String getShowViewQuery(DatabaseInfo info) { return null; } public String getShowSequenceQuery(DatabaseInfo info) { return null; } /** * @param connection - * a database * @param schema - * a schema name to filter on, or null to return all entities from all filters * @param type - * the type of entities (TABLES, VIEWS, etc.) to get * @return */ protected List getEntitiesList(Bookmark bookmark, Connection connection, String type) throws SQLException { List list = new ArrayList(); DatabaseMetaData metaData = connection.getMetaData(); ResultSet set = metaData.getTables( null, bookmark.getSchema(), "%", new String[] { type }); while (set.next()) { String schema = set.getString("TABLE_SCHEM"); schema = (schema == null) ? "" : schema.trim(); String tableName = set.getString("TABLE_NAME").trim(); if (tableName.length() > 0) { Entity entity = EntityFactory.getInstance().create( bookmark, schema, tableName, type); if (entity != null) { list.add(entity); } } } set.close(); return list; } }