예제 #1
0
 /////////////// private
 private DataSource getDataSource() throws Exception {
   FileSystem fs = getFileSystem();
   jdbcDataSource ds = new jdbcDataSource();
   ds.setDatabase("jdbc:hsqldb:.");
   ds.setUser("sa");
   ds.setPassword("");
   if (!DatabaseUtils.hasTable(ds, "ledge_id_table")) {
     DatabaseUtils.runScript(ds, fs.getReader("sql/database/IdGeneratorTables.sql", "UTF-8"));
   }
   if (!DatabaseUtils.hasTable(ds, "ledge_naming_context")) {
     DatabaseUtils.runScript(ds, fs.getReader("sql/naming/DBNamingTables.sql", "UTF-8"));
   }
   DatabaseUtils.runScript(ds, fs.getReader("sql/naming/DBNamingTest.sql", "UTF-8"));
   return ds;
 }
예제 #2
0
 private void runScript(String path) throws Exception {
   logger.info("running " + adapt(path));
   Reader scriptReader = fileSystem.getReader(adapt(path), "UTF-8");
   if (scriptReader == null) {
     throw new IOException("script " + path + " missing from classpath");
   }
   DatabaseUtils.runScript(dataSource, scriptReader);
 }