@Test public void testListTables() throws SQLException { ResultSet rs = mock(ResultSet.class); when(rs.next()).thenReturn(true).thenReturn(true).thenReturn(true).thenReturn(false); when(rs.getString("TABLE_NAME")).thenReturn("KYLIN_SALES").thenReturn("CAT_DT").thenReturn("KYLIN_CAT"); String catalog = "testCatalog"; when(connection.getMetaData()).thenReturn(dbmd); when(dbmd.getTables(catalog, null, null, null)).thenReturn(rs); List<String> tables = jdbcMetadata.listTables(catalog); Assert.assertEquals(3, tables.size()); Assert.assertEquals("CAT_DT", tables.get(1)); }
@Override public List<String> listTables(String catalog) throws SQLException { List<String> ret = new ArrayList<>(); try (Connection con = SqlUtil.getConnection(dbconf); ResultSet res = con.getMetaData().getTables(catalog, null, null, null)) { String table; while (res.next()) { table = res.getString("TABLE_NAME"); ret.add(table); } } return ret; }
MySQLJdbcMetadata extends DefaultJdbcMetadata { @Override public List<String> listTables(String catalog) throws SQLException { List<String> ret = new ArrayList<>(); try (Connection con = SqlUtil.getConnection(dbconf); ResultSet res = con.getMetaData().getTables(catalog, null, null, null)) { String table; while (res.next()) { table = res.getString("TABLE_NAME"); ret.add(table); } } return ret; } }
MySQLJdbcMetadata extends DefaultJdbcMetadata { @Override public List<String> listTables(String catalog) throws SQLException { List<String> ret = new ArrayList<>(); try (Connection con = SqlUtil.getConnection(dbconf); ResultSet res = con.getMetaData().getTables(catalog, null, null, null)) { String table; while (res.next()) { table = res.getString("TABLE_NAME"); ret.add(table); } } return ret; } MySQLJdbcMetadata(DBConnConf dbConnConf); }
MySQLJdbcMetadata extends DefaultJdbcMetadata { @Override public List<String> listTables(String catalog) throws SQLException { List<String> ret = new ArrayList<>(); try (Connection con = SqlUtil.getConnection(dbconf); ResultSet res = con.getMetaData().getTables(catalog, null, null, null)) { String table; while (res.next()) { table = res.getString("TABLE_NAME"); ret.add(table); } } return ret; } MySQLJdbcMetadata(DBConnConf dbConnConf); @Override List<String> listDatabases(); @Override List<String> listTables(String catalog); @Override ResultSet listColumns(final DatabaseMetaData dbmd, String catalog, String table); @Override ResultSet getTable(final DatabaseMetaData dbmd, String catalog, String table); @Override SourceDialect getDialect(); }
MySQLJdbcMetadata extends DefaultJdbcMetadata { @Override public List<String> listTables(String catalog) throws SQLException { List<String> ret = new ArrayList<>(); try (Connection con = SqlUtil.getConnection(dbconf); ResultSet res = con.getMetaData().getTables(catalog, null, null, null)) { String table; while (res.next()) { table = res.getString("TABLE_NAME"); ret.add(table); } } return ret; } MySQLJdbcMetadata(DBConnConf dbConnConf); @Override List<String> listDatabases(); @Override List<String> listTables(String catalog); @Override ResultSet listColumns(final DatabaseMetaData dbmd, String catalog, String table); @Override ResultSet getTable(final DatabaseMetaData dbmd, String catalog, String table); @Override SourceDialect getDialect();  }