Exemplo n.º 1
0
  public static void main(String[] args) {
    DbInstance dbinstance =
        new DbInstance(
            false, // pooled
            "null", // datasourcePath
            "<REPLACE_WITH_DB_URL>", // dbUrl
            "qsmaster",
            null,
            "com.mysql.jdbc.Driver",
            "lsstdb");
    DataSource ds = JdbcFactory.getDataSource(dbinstance);

    String sql = "select * from DeepSource where qserv_areaspec_box(0.4, 1.05, 0.5, 1.15)";

    Connection conn = null;
    try {
      conn = DataSourceUtils.getConnection(ds);
      long cTime = System.currentTimeMillis();

      Statement stmt = null;
      try {
        stmt = conn.createStatement();
        _log.briefDebug("Executing SQL query: " + sql);
        // ResultSet rs = stmt.executeQuery(sql);
        // _log.briefDebug ("SELECT took "+(System.currentTimeMillis()-cTime)+"ms");
        File file = new File("/tmp/lsstTest.tbl");
        IpacTableExtractor.query(null, ds, file, 10000, sql);
        _log.briefDebug("SELECT took " + (System.currentTimeMillis() - cTime) + "ms");
      } catch (Exception e) {
        System.out.println("Exception " + e.getMessage());
      } finally {
        closeStatement(stmt);
      }

    } catch (Exception e) {
      System.out.println("Exception " + e.getMessage());
      e.printStackTrace();
    } finally {
      if (conn != null) {
        DataSourceUtils.releaseConnection(conn, ds);
      }
    }
  }