// //////////////////////////////////////////////// // //////////////////////////////////////////////// // Test Methods // //////////////////////////////////////////////// // //////////////////////////////////////////////// @Test public void LemnaTecDatabaseConfigurationFileConfiguredCorrectly() throws IOException { try { DataSource lemnaTecDatabase = Config.experimentDataSource("LTSystem"); assertNotNull(lemnaTecDatabase); } catch (MalformedConfigException e) { fail("Configuration file missing fields."); } }
// //////////////////////////////////////////////// // //////////////////////////////////////////////// // Database Access Helper Methods // //////////////////////////////////////////////// // //////////////////////////////////////////////// private List<String> GetDatabaseNames() throws MalformedConfigException, IOException { DataSource lemnaTecDatabase = Config.experimentDataSource("LTSystem"); String getDatabases = "SELECT name FROM ltdbs WHERE removed = FALSE"; JdbcTemplate jdbcTemplate = new JdbcTemplate(lemnaTecDatabase); List<String> databaseNames = jdbcTemplate.query(getDatabases, new ParseLemnaTecDatabaseNames()); return databaseNames; }
private List<String> GetTableNames(String databaseName) throws MalformedConfigException, IOException { DataSource experimentDatabase = Config.experimentDataSource(databaseName); String getTables = "SELECT table_name FROM INFORMATION_SCHEMA.TABLES"; JdbcTemplate jdbcTemplate = new JdbcTemplate(experimentDatabase); List<String> tableNames = jdbcTemplate.query(getTables, new ParsePostgreSQLTableNames()); return tableNames; }
private List<String> GetColumnNames(String table, String databaseName) throws MalformedConfigException, IOException { DataSource experimentDatabase = Config.experimentDataSource(databaseName); String getColumns = "SELECT column_name FROM INFORMATION_SCHEMA.COLUMNS WHERE table_name = '" + table + "'"; JdbcTemplate jdbcTemplate = new JdbcTemplate(experimentDatabase); List<String> columnNames = jdbcTemplate.query(getColumns, new ParsePostgreSQLColumnNames()); return columnNames; }