List of usage examples for java.sql DatabaseMetaData getColumns
ResultSet getColumns(String catalog, String schemaPattern, String tableNamePattern, String columnNamePattern)
throws SQLException;
From source file:org.talend.core.model.metadata.builder.database.manager.ExtractManager.java
protected ResultSet getColumnsResultSet(DatabaseMetaData dbMetaData, String catalogName, String schemaName, String tableName) throws SQLException { ResultSet columns = null;//w w w . jav a 2s . co m if (dbMetaData != null) { if (tableName.contains("/")) {//$NON-NLS-1$ tableName = tableName.replaceAll("/", "//");//$NON-NLS-1$ //$NON-NLS-2$ } columns = dbMetaData.getColumns(catalogName, schemaName, tableName, null); } return columns; }
From source file:org.finra.herd.service.impl.RelationalTableRegistrationHelperServiceImpl.java
/** * Retrieves a list of actual schema columns for the specified relational table. This method uses actual JDBC connection to retrieve a description of table * columns./*from w w w .j a v a2 s.co m*/ * * @param relationalStorageAttributesDto the relational storage attributes DTO * @param relationalSchemaName the name of the relational database schema * @param relationalTableName the name of the relational table * * @return the list of schema columns for the specified relational table */ List<SchemaColumn> retrieveRelationalTableColumnsImpl( RelationalStorageAttributesDto relationalStorageAttributesDto, String relationalSchemaName, String relationalTableName) { // Get the JDBC password value. String password = getPassword(relationalStorageAttributesDto); // Create and initialize a driver manager data source (a simple implementation of the standard JDBC interface). // We only support PostgreSQL database type. DriverManagerDataSource driverManagerDataSource = new DriverManagerDataSource(); driverManagerDataSource.setUrl(relationalStorageAttributesDto.getJdbcUrl()); driverManagerDataSource.setUsername(relationalStorageAttributesDto.getJdbcUsername()); driverManagerDataSource.setPassword(password); driverManagerDataSource.setDriverClassName(JdbcServiceImpl.DRIVER_POSTGRES); // Create an empty result list. List<SchemaColumn> schemaColumns = new ArrayList<>(); // Connect to the database and retrieve the relational table columns. try (Connection connection = driverManagerDataSource.getConnection()) { DatabaseMetaData databaseMetaData = connection.getMetaData(); // Check if the specified relational table exists in the database. try (ResultSet tables = databaseMetaData.getTables(null, relationalSchemaName, relationalTableName, null)) { Assert.isTrue(tables.next(), String.format( "Relational table with \"%s\" name not found under \"%s\" schema at jdbc.url=\"%s\" for jdbc.username=\"%s\".", relationalTableName, relationalSchemaName, driverManagerDataSource.getUrl(), driverManagerDataSource.getUsername())); } // Retrieve the relational table columns. try (ResultSet columns = databaseMetaData.getColumns(null, relationalSchemaName, relationalTableName, null)) { while (columns.next()) { SchemaColumn schemaColumn = new SchemaColumn(); schemaColumn.setName(columns.getString("COLUMN_NAME")); schemaColumn.setType(columns.getString("TYPE_NAME")); schemaColumn.setSize(columns.getString("COLUMN_SIZE")); schemaColumn.setRequired(columns.getInt("NULLABLE") == 0); schemaColumn.setDefaultValue(columns.getString("COLUMN_DEF")); schemaColumns.add(schemaColumn); } } } catch (SQLException e) { throw new IllegalArgumentException(String.format( "Failed to retrieve description of a relational table with \"%s\" name under \"%s\" schema " + "at jdbc.url=\"%s\" using jdbc.username=\"%s\". Reason: %s", relationalTableName, relationalSchemaName, driverManagerDataSource.getUrl(), driverManagerDataSource.getUsername(), e.getMessage()), e); } return schemaColumns; }
From source file:org.executequery.databaseobjects.impl.DefaultDatabaseHost.java
/** * Returns the columns of the specified database object. * * @param catalog the table catalog name * @param schema the table schema name/*from w w w . j a va2 s. c o m*/ * @param table the database object name * @return the columns */ public List<DatabaseColumn> getColumns(String catalog, String schema, String table) throws DataSourceException { ResultSet rs = null; List<DatabaseColumn> columns = new ArrayList<DatabaseColumn>(); try { String _catalog = getCatalogNameForQueries(catalog); String _schema = getSchemaNameForQueries(schema); DatabaseMetaData dmd = getDatabaseMetaData(); // retrieve the base column info rs = dmd.getColumns(_catalog, _schema, table, null); /* if (Log.isDebugEnabled()) { Log.debug("Meta data on columns for table - " + table); ResultSetMetaData metaData = rs.getMetaData(); int columnCount = metaData.getColumnCount(); for (int i = 0; i < columnCount; i++) { Log.debug("Column: [ " + (i + 1) + " ] " + metaData.getColumnName(i + 1)); } } */ while (rs.next()) { DefaultDatabaseColumn column = new DefaultDatabaseColumn(); column.setCatalogName(catalog); column.setSchemaName(schema); column.setName(rs.getString(4)); column.setTypeInt(rs.getInt(5)); column.setTypeName(rs.getString(6)); column.setColumnSize(rs.getInt(7)); column.setColumnScale(rs.getInt(9)); column.setRequired(rs.getInt(11) == DatabaseMetaData.columnNoNulls); column.setRemarks(rs.getString(12)); column.setDefaultValue(rs.getString(13)); columns.add(column); } releaseResources(rs); int columnCount = columns.size(); if (columnCount > 0) { // check for primary keys rs = dmd.getPrimaryKeys(_catalog, _schema, table); while (rs.next()) { String pkColumn = rs.getString(4); // find the pk column in the previous list for (int i = 0; i < columnCount; i++) { DatabaseColumn column = columns.get(i); String columnName = column.getName(); if (columnName.equalsIgnoreCase(pkColumn)) { ((DefaultDatabaseColumn) column).setPrimaryKey(true); break; } } } releaseResources(rs); // check for foreign keys rs = dmd.getImportedKeys(_catalog, _schema, table); while (rs.next()) { String fkColumn = rs.getString(8); // find the fk column in the previous list for (int i = 0; i < columnCount; i++) { DatabaseColumn column = columns.get(i); String columnName = column.getName(); if (columnName.equalsIgnoreCase(fkColumn)) { ((DefaultDatabaseColumn) column).setForeignKey(true); break; } } } } return columns; } catch (SQLException e) { if (Log.isDebugEnabled()) { Log.error("Error retrieving column data for table " + table + " using connection " + getDatabaseConnection(), e); } return columns; // throw new DataSourceException(e); } finally { releaseResources(rs); } }
From source file:org.executequery.databaseobjects.impl.DefaultDatabaseHost.java
/** * Returns the column names of the specified database object. * * @param catalog the table catalog name * @param schema the table schema name//from ww w.j a v a 2s.c o m * @param table the database object name * @return the column names */ public List<ColumnInformation> getColumnInformation(String catalog, String schema, String table) throws DataSourceException { ResultSet rs = null; List<ColumnInformation> columns = new ArrayList<ColumnInformation>(); try { String _catalog = getCatalogNameForQueries(catalog); String _schema = getSchemaNameForQueries(schema); DatabaseMetaData dmd = getDatabaseMetaData(); if (!isConnected()) { return new ArrayList<ColumnInformation>(0); } // retrieve the base column info rs = dmd.getColumns(_catalog, _schema, table, null); while (rs.next()) { String name = rs.getString(4); columns.add(columnInformationFactory.build(table, name, rs.getString(6), rs.getInt(5), rs.getInt(7), rs.getInt(9), rs.getInt(11) == DatabaseMetaData.columnNoNulls)); } return columns; } catch (SQLException e) { if (Log.isDebugEnabled()) { Log.error("Error retrieving column data for table " + table + " using connection " + getDatabaseConnection(), e); } return columns; } finally { releaseResources(rs); } }
From source file:it.eng.spagobi.meta.initializer.PhysicalModelInitializer.java
private void initColumnsMeta(DatabaseMetaData dbMeta, PhysicalModel model, PhysicalTable table) { ResultSet rs;// w w w . ja v a 2s . c o m PhysicalColumn column; try { rs = dbMeta.getColumns(model.getCatalog(), model.getSchema(), table.getName(), null); /* * 1. TABLE_CAT String => table catalog (may be null) 2. TABLE_SCHEM String => table schema (may be null) 3. TABLE_NAME String => table name 4. * COLUMN_NAME String => column name 5. DATA_TYPE short => SQL type from java.sql.Types 6. TYPE_NAME String => Data source dependent type name, for * a UDT the type name is fully qualified 7. COLUMN_SIZE int => column size. For char or date types this is the maximum number of characters, for * numeric or decimal types this is precision. 8. BUFFER_LENGTH is not used. 9. DECIMAL_DIGITS int => the number of fractional digits 10. * NUM_PREC_RADIX int => Radix (typically either 10 or 2) 11. NULLABLE int => is NULL allowed. columnNoNulls - might not allow NULL values; * columnNullable - definitely allows NULL values; columnNullableUnknown - nullability unknown 12. REMARKS String => comment describing column (may * be null) 13. COLUMN_DEF String => default value (may be null) 14. SQL_DATA_TYPE int => unused 15. SQL_DATETIME_SUB int => unused 16. * CHAR_OCTET_LENGTH int => for char types the maximum number of bytes in the column 17. ORDINAL_POSITION int => index of column in table (starting * at 1) 18. IS_NULLABLE String => NO means column definitely does not allow NULL values; YES means the column might allow NULL values. An empty * string means nobody knows. 19. SCOPE_CATLOG String => catalog of table that is the scope of a reference attribute (null if DATA_TYPE isnt REF) * 20. SCOPE_SCHEMA String => schema of table that is the scope of a * * 182 Chapter 5 reference attribute (null if the DATA_TYPE isnt REF) 21. SCOPE_TABLE String => table name that is the scope of a reference * attribute (null if the DATA_TYPE isnt REF) 22. SOURCE_DATA_TYPE short => source type of a distinct type or user-generated Ref type, SQL type * from java.sql.Types (null if DATA_TYPE isnt DISTINCT or user-generated REF) */ while (rs.next()) { column = FACTORY.createPhysicalColumn(); // to prevent ojdbc bug try { column.setDefaultValue(rs.getString("COLUMN_DEF")); } catch (Throwable t) { log("Impossible to set Default column value"); t.printStackTrace(); column.setDefaultValue(null); } column.setName(rs.getString("COLUMN_NAME")); column.setComment(getEscapedMetadataPropertyValue(rs, "REMARKS")); column.setDataType(JDBCTypeMapper.getModelType(rs.getShort("DATA_TYPE"))); column.setTypeName(rs.getString("TYPE_NAME")); column.setSize(rs.getInt("COLUMN_SIZE")); column.setOctectLength(rs.getInt("CHAR_OCTET_LENGTH")); column.setDecimalDigits(rs.getInt("DECIMAL_DIGITS")); column.setRadix(rs.getInt("NUM_PREC_RADIX")); // column.setDefaultValue( rs.getString("COLUMN_DEF") ); column.setNullable(!"NO".equalsIgnoreCase(rs.getString("IS_NULLABLE"))); column.setPosition(rs.getInt("ORDINAL_POSITION")); table.getColumns().add(column); log(" - column: " + column.getName() + " [" + column.getTypeName() + "]" + " [" + column.getDefaultValue() + "]"); getPropertiesInitializer().addProperties(column); } rs.close(); } catch (Throwable t) { throw new RuntimeException("Impossible to initialize primaryKeys metadata", t); } }
From source file:org.nuclos.server.dblayer.impl.standard.StandardSqlDBAccess.java
protected List<String> getColumns(final String tableOrView) { try {/*from w ww .java2s. c o m*/ return executor.execute(new ConnectionRunner<List<String>>() { @Override public List<String> perform(Connection conn) throws SQLException { final DatabaseMetaData meta = conn.getMetaData(); // we NEED toLowerCase() here, at least for PostgreSQL (tp) final ResultSet columns = meta.getColumns(catalog, schema, tableOrView.toLowerCase(), "%"); final List<String> result = new ArrayList<String>(); while (columns.next()) { result.add(columns.getString("COLUMN_NAME")); } if (result.size() == 0) { throw new IllegalArgumentException("Table " + tableOrView + " with no columns?"); } return result; } }); } catch (SQLException e) { LOG.error("getColumns failed with " + e.toString()); throw wrapSQLException(null, "getColumns failed", e); } }
From source file:org.wso2.carbon.dataservices.core.odata.RDBMSDataHandler.java
/** * This method reads table column meta data. * * @param tableName Name of the table// w w w . java 2 s . co m * @return table MetaData * @throws ODataServiceFault */ private Map<String, DataColumn> readTableColumnMetaData(String tableName, DatabaseMetaData meta) throws ODataServiceFault { ResultSet resultSet = null; Map<String, DataColumn> columnMap = new HashMap<>(); try { resultSet = meta.getColumns(null, null, tableName, null); int i = 1; while (resultSet.next()) { String columnName = resultSet.getString("COLUMN_NAME"); int columnType = resultSet.getInt("DATA_TYPE"); int size = resultSet.getInt("COLUMN_SIZE"); boolean nullable = resultSet.getBoolean("NULLABLE"); String columnDefaultVal = resultSet.getString("COLUMN_DEF"); int precision = resultSet.getMetaData().getPrecision(i); int scale = resultSet.getMetaData().getScale(i); DataColumn column = new DataColumn(columnName, getODataDataType(columnType), i, nullable, size); if (null != columnDefaultVal) { column.setDefaultValue(columnDefaultVal); } if (Types.DOUBLE == columnType || Types.FLOAT == columnType || Types.DECIMAL == columnType || Types.NUMERIC == columnType || Types.REAL == columnType) { column.setPrecision(precision); if (scale == 0) { //setting default scale as 5 column.setScale(precision); } else { column.setScale(scale); } } columnMap.put(columnName, column); addDataType(tableName, columnName, columnType); i++; } return columnMap; } catch (SQLException e) { throw new ODataServiceFault(e, "Error in reading table meta data in " + tableName + " table. :" + e.getMessage()); } finally { releaseResources(resultSet, null); } }
From source file:com.intellectualcrafters.plot.database.SQLManager.java
/** * @return/* w w w . j av a 2s . c o m*/ */ @Override public LinkedHashMap<String, HashMap<PlotId, Plot>> getPlots() { final LinkedHashMap<String, HashMap<PlotId, Plot>> newplots = new LinkedHashMap<String, HashMap<PlotId, Plot>>(); try { final DatabaseMetaData data = connection.getMetaData(); ResultSet rs = data.getColumns(null, null, prefix + "plot", "plot_id"); final boolean execute = rs.next(); if (execute) { final Statement statement = connection.createStatement(); statement.addBatch("ALTER IGNORE TABLE `" + prefix + "plot` ADD `plot_id_x` int(11) DEFAULT 0"); statement.addBatch("ALTER IGNORE TABLE `" + prefix + "plot` ADD `plot_id_z` int(11) DEFAULT 0"); statement.addBatch("UPDATE `" + prefix + "plot` SET\n" + " `plot_id_x` = IF(" + " LOCATE(';', `plot_id`) > 0," + " SUBSTRING(`plot_id`, 1, LOCATE(';', `plot_id`) - 1)," + " `plot_id`" + " )," + " `plot_id_z` = IF(" + " LOCATE(';', `plot_id`) > 0," + " SUBSTRING(`plot_id`, LOCATE(';', `plot_id`) + 1)," + " NULL" + " )"); statement.addBatch("ALTER TABLE `" + prefix + "plot` DROP `plot_id`"); statement.addBatch( "ALTER IGNORE TABLE `" + prefix + "plot_settings` ADD `flags` VARCHAR(512) DEFAULT NULL"); statement.executeBatch(); statement.close(); } rs = data.getColumns(null, null, prefix + "plot_settings", "merged"); if (!rs.next()) { final Statement statement = connection.createStatement(); statement.addBatch("ALTER TABLE `" + prefix + "plot_settings` ADD `merged` int(11) DEFAULT NULL"); statement.executeBatch(); statement.close(); } } catch (final Exception e) { e.printStackTrace(); } final HashMap<Integer, Plot> plots = new HashMap<Integer, Plot>(); Statement stmt = null; try { Set<String> worlds = new HashSet<String>(); if (PlotMain.config.contains("worlds")) { worlds = PlotMain.config.getConfigurationSection("worlds").getKeys(false); } final HashMap<String, UUID> uuids = new HashMap<String, UUID>(); final HashMap<String, Integer> noExist = new HashMap<String, Integer>(); /* * Getting plots */ stmt = connection.createStatement(); ResultSet r = stmt.executeQuery( "SELECT `id`, `plot_id_x`, `plot_id_z`, `owner`, `world` FROM `" + prefix + "plot`"); PlotId plot_id; int id; Plot p; String o; UUID user; while (r.next()) { plot_id = new PlotId(r.getInt("plot_id_x"), r.getInt("plot_id_z")); id = r.getInt("id"); final String worldname = r.getString("world"); if (!worlds.contains(worldname)) { if (noExist.containsKey(worldname)) { noExist.put(worldname, noExist.get(worldname) + 1); } else { noExist.put(worldname, 1); } } o = r.getString("owner"); user = uuids.get(o); if (user == null) { user = UUID.fromString(o); uuids.put(o, user); } p = new Plot(plot_id, user, Biome.FOREST, new ArrayList<UUID>(), new ArrayList<UUID>(), new ArrayList<UUID>(), "", PlotHomePosition.DEFAULT, null, worldname, new boolean[] { false, false, false, false }); plots.put(id, p); } // stmt.close(); /* * Getting helpers */ // stmt = connection.createStatement(); r = stmt.executeQuery("SELECT `user_uuid`, `plot_plot_id` FROM `" + prefix + "plot_helpers`"); while (r.next()) { id = r.getInt("plot_plot_id"); o = r.getString("user_uuid"); user = uuids.get(o); if (user == null) { user = UUID.fromString(o); uuids.put(o, user); } final Plot plot = plots.get(id); if (plot != null) { plot.addHelper(user); } else { PlotMain.sendConsoleSenderMessage("&cPLOT " + id + " in plot_helpers does not exist. Please create the plot or remove this entry."); } } // stmt.close(); /* * Getting trusted */ // stmt = connection.createStatement(); r = stmt.executeQuery("SELECT `user_uuid`, `plot_plot_id` FROM `" + prefix + "plot_trusted`"); while (r.next()) { id = r.getInt("plot_plot_id"); o = r.getString("user_uuid"); user = uuids.get(o); if (user == null) { user = UUID.fromString(o); uuids.put(o, user); } final Plot plot = plots.get(id); if (plot != null) { plot.addTrusted(user); } else { PlotMain.sendConsoleSenderMessage("&cPLOT " + id + " in plot_trusted does not exist. Please create the plot or remove this entry."); } } // stmt.close(); /* * Getting denied */ // stmt = connection.createStatement(); r = stmt.executeQuery("SELECT `user_uuid`, `plot_plot_id` FROM `" + prefix + "plot_denied`"); while (r.next()) { id = r.getInt("plot_plot_id"); o = r.getString("user_uuid"); user = uuids.get(o); if (user == null) { user = UUID.fromString(o); uuids.put(o, user); } final Plot plot = plots.get(id); if (plot != null) { plot.addDenied(user); } else { PlotMain.sendConsoleSenderMessage("&cPLOT " + id + " in plot_denied does not exist. Please create the plot or remove this entry."); } } // stmt.close(); // stmt = connection.createStatement(); r = stmt.executeQuery("SELECT * FROM `" + prefix + "plot_settings`"); while (r.next()) { id = r.getInt("plot_plot_id"); final Plot plot = plots.get(id); if (plot != null) { final String b = r.getString("biome"); Biome biome = null; if (b != null) { for (final Biome mybiome : Biome.values()) { if (mybiome.toString().equalsIgnoreCase(b)) { biome = mybiome; break; } } } final String alias = r.getString("alias"); if (alias != null) { plot.settings.setAlias(alias); } final String pos = r.getString("position"); if (pos != null) { for (final PlotHomePosition plotHomePosition : PlotHomePosition.values()) { if (plotHomePosition.isMatching(pos)) { if (plotHomePosition != PlotHomePosition.DEFAULT) { plot.settings.setPosition(plotHomePosition); } break; } } } final Integer m = r.getInt("merged"); if (m != null) { final boolean[] merged = new boolean[4]; for (int i = 0; i < 4; i++) { merged[3 - i] = ((m) & (1 << i)) != 0; } plot.settings.setMerged(merged); } else { plot.settings.setMerged(new boolean[] { false, false, false, false }); } String[] flags_string; final String myflags = r.getString("flags"); if (myflags == null) { flags_string = new String[] {}; } else { flags_string = myflags.split(","); } final ArrayList<Flag> flags = new ArrayList<Flag>(); boolean exception = false; for (final String element : flags_string) { if (element.contains(":")) { final String[] split = element.split(":"); try { flags.add(new Flag(FlagManager.getFlag(split[0], true), split[1].replaceAll("\u00AF", ":").replaceAll("", ","))); } catch (final Exception e) { exception = true; } } else { flags.add(new Flag(FlagManager.getFlag(element, true), "")); } } if (exception) { PlotMain.sendConsoleSenderMessage( "&cPlot " + id + " had an invalid flag. A fix has been attempted."); setFlags(id, flags.toArray(new Flag[0])); } plot.settings.setFlags(flags.toArray(new Flag[0])); } else { PlotMain.sendConsoleSenderMessage("&cPLOT " + id + " in plot_settings does not exist. Please create the plot or remove this entry."); } } stmt.close(); for (final Plot plot : plots.values()) { final String world = plot.world; if (!newplots.containsKey(world)) { newplots.put(world, new HashMap<PlotId, Plot>()); } newplots.get(world).put(plot.id, plot); } boolean invalidPlot = false; for (final String worldname : noExist.keySet()) { invalidPlot = true; PlotMain.sendConsoleSenderMessage("&c[WARNING] Found " + noExist.get(worldname) + " plots in DB for non existant world; '" + worldname + "'."); } if (invalidPlot) { PlotMain.sendConsoleSenderMessage( "&c[WARNING] - Please create the world/s or remove the plots using the purge command"); } } catch (final SQLException e) { Logger.add(LogLevel.WARNING, "Failed to load plots."); e.printStackTrace(); } return newplots; }
From source file:org.jumpmind.db.platform.AbstractJdbcDdlReader.java
public List<String> getColumnNames(final String catalog, final String schema, final String tableName) { JdbcSqlTemplate sqlTemplate = (JdbcSqlTemplate) platform.getSqlTemplate(); return sqlTemplate.execute(new IConnectionCallback<List<String>>() { public List<String> execute(Connection connection) throws SQLException { ArrayList<String> list = new ArrayList<String>(); DatabaseMetaData meta = connection.getMetaData(); ResultSet rs = null;/*from ww w .ja v a 2 s . co m*/ try { rs = meta.getColumns(catalog, schema, tableName, null); while (rs.next()) { String tableName = rs.getString("COLUMN_NAME"); list.add(tableName); } return list; } finally { close(rs); } } }); }
From source file:com.micromux.cassandra.jdbc.JdbcRegressionTest.java
/** * Test the meta-data logic for the database. This should allow you to query the * schema information dynamically. Previously this was <i>Issue 40</i>. */// w w w . ja v a 2 s . com @Test public void testDatabaseMetaData() throws Exception { DatabaseMetaData md = con.getMetaData(); // test various retrieval methods ResultSet result = md.getTables(con.getCatalog(), null, "%", new String[] { "TABLE" }); assertTrue("Make sure we have found a table", result.next()); result = md.getTables(null, KEYSPACE, TABLE, null); assertTrue("Make sure we have found the table asked for", result.next()); result = md.getTables(null, KEYSPACE, TABLE, new String[] { "TABLE" }); assertTrue("Make sure we have found the table asked for", result.next()); result = md.getTables(con.getCatalog(), KEYSPACE, TABLE, new String[] { "TABLE" }); assertTrue("Make sure we have found the table asked for", result.next()); // check the table name String tn = result.getString("TABLE_NAME"); assertEquals("Table name match", TABLE, tn); System.out.println("Found table via dmd : " + tn); // load the columns result = md.getColumns(con.getCatalog(), KEYSPACE, TABLE, null); assertTrue("Make sure we have found first column", result.next()); assertEquals("Make sure table name match", TABLE, result.getString("TABLE_NAME")); String cn = result.getString("COLUMN_NAME"); System.out.println("Found (default) PK column : " + cn); assertEquals("Column name check", "keyname", cn); assertEquals("Column type check", Types.VARCHAR, result.getInt("DATA_TYPE")); assertTrue("Make sure we have found second column", result.next()); cn = result.getString("COLUMN_NAME"); System.out.println("Found column : " + cn); assertEquals("Column name check", "bvalue", cn); assertEquals("Column type check", Types.BOOLEAN, result.getInt("DATA_TYPE")); assertTrue("Make sure we have found thirth column", result.next()); cn = result.getString("COLUMN_NAME"); System.out.println("Found column : " + cn); assertEquals("Column name check", "ivalue", cn); assertEquals("Column type check", Types.INTEGER, result.getInt("DATA_TYPE")); // make sure we filter result = md.getColumns(con.getCatalog(), KEYSPACE, TABLE, "bvalue"); result.next(); assertFalse("Make sure we have found requested column only", result.next()); }