Tabnine Logo
DataBaseConnector.obtainOrReserveConnection
Code IndexAdd Tabnine to your IDE (free)

How to use
obtainOrReserveConnection
method
in
de.julielab.xmlData.dataBase.DataBaseConnector

Best Java code snippets using de.julielab.xmlData.dataBase.DataBaseConnector.obtainOrReserveConnection (Showing top 16 results out of 315)

origin: de.julielab/jcore-xmi-db-reader

  private void determineDataInGzipFormat(String table) throws ResourceInitializationException {
    doGzip = true;
    dataTable = dbc.getNextOrThisDataTable(table);
    log.debug("Fetching a single row from data table {} in order to determine whether data is in GZIP format", dataTable);
    try (CoStoSysConnection conn = dbc.obtainOrReserveConnection()){
      ResultSet rs = conn.createStatement().executeQuery(String.format("SELECT xmi FROM %s LIMIT 1", dataTable));
      while (rs.next()) {
        byte[] xmiData = rs.getBytes("xmi");
        try (GZIPInputStream gzis = new GZIPInputStream(new ByteArrayInputStream(xmiData))) {
          gzis.read();
        } catch (IOException e) {
          log.debug("Attempt to read XMI data in GZIP format failed. Assuming non-gzipped XMI data. Expected exception:", e);
          doGzip = false;
        }
      }
    } catch (SQLException e) {
      if (e.getMessage().contains("does not exist"))
        log.error("An exception occurred when trying to read the xmi column of the data table \"{}\". It seems the table does not contain XMI data and this is invalid to use with this reader.", dataTable);
      throw new ResourceInitializationException(e);
    }
  }
}
origin: de.julielab/jcore-xmi-db-reader

private void determineDataInGzipFormat(String table) throws ResourceInitializationException {
  doGzip = true;
  dataTable = dbc.getNextOrThisDataTable(table);
  log.debug("Fetching a single row from data table {} in order to determine whether data is in GZIP format", dataTable);
  try (CoStoSysConnection conn = dbc.obtainOrReserveConnection()){
    ResultSet rs = conn.createStatement().executeQuery(String.format("SELECT xmi FROM %s LIMIT 1", dataTable));
    while (rs.next()) {
      byte[] xmiData = rs.getBytes("xmi");
      try (GZIPInputStream gzis = new GZIPInputStream(new ByteArrayInputStream(xmiData))) {
        gzis.read();
      } catch (IOException e) {
        log.debug("Attempt to read XMI data in GZIP format failed. Assuming non-gzipped XMI data. Expected exception:", e);
        doGzip = false;
      }
    }
  } catch (SQLException e) {
    if (e.getMessage().contains("does not exist"))
      log.error("An exception occurred when trying to read the xmi column of the data table \"{}\". It seems the table does not contain XMI data and this is invalid to use with this reader.", dataTable);
    throw new ResourceInitializationException(e);
  }
}
origin: de.julielab/jcore-xmi-db-reader

  private void determineDataInGzipFormat(String table) throws ResourceInitializationException {
    doGzip = true;
    dataTable = dbc.getNextOrThisDataTable(table);
    log.debug("Fetching a single row from data table {} in order to determine whether data is in GZIP format", dataTable);
    try (CoStoSysConnection conn = dbc.obtainOrReserveConnection()) {
      ResultSet rs = conn.createStatement().executeQuery(String.format("SELECT xmi FROM %s LIMIT 1", dataTable));
      while (rs.next()) {
        byte[] xmiData = rs.getBytes("xmi");
        try (GZIPInputStream gzis = new GZIPInputStream(new ByteArrayInputStream(xmiData))) {
          gzis.read();
        } catch (IOException e) {
          log.debug("Attempt to read XMI data in GZIP format failed. Assuming non-gzipped XMI data. Expected exception:", e);
          doGzip = false;
        }
      }
    } catch (SQLException e) {
      if (e.getMessage().contains("does not exist"))
        log.error("An exception occurred when trying to read the xmi column of the data table \"{}\". It seems the table does not contain XMI data and this is invalid to use with this reader.", dataTable);
      throw new ResourceInitializationException(e);
    }
  }
}
origin: de.julielab/jcore-xmi-db-writer

/**
 * Adds the extract string <tt>tablename</tt> to the list of annotation
 * table names.
 *
 * @param tablename
 */
void addAnnotationTableToList(String tablename) {
  try (CoStoSysConnection conn = dbc.obtainOrReserveConnection()){
    conn.setAutoCommit(true);
    Statement stmt = conn.createStatement();
    String template = "INSERT INTO %s VALUES('%s')";
    String sql = String.format(template, dbc.getActiveDataPGSchema() + "." + ANNOTATION_LIST_TABLE, tablename);
    stmt.execute(sql);
  } catch (PSQLException e) {
    log.debug("Tried to add already existing annotation table to annotation list: \"{}\", ignoring.",
        tablename);
  } catch (SQLException e) {
    e.printStackTrace();
    SQLException ne = e.getNextException();
    if (null != ne)
      ne.printStackTrace();
  }
}
origin: de.julielab/jcore-db-reader

try (CoStoSysConnection ignored = dbc.obtainOrReserveConnection()) {
  log.trace("Using connection {} to retrieveAndMark", ignored.getConnection());
  ids = dbc.retrieveAndMark(tableName, getClass().getSimpleName(), hostName, pid, limit, selectionOrder);
origin: de.julielab/jcore-xmi-db-writer

private void createNamespaceTable(DataBaseConnector dbc) {
  if (!dbc.tableExists(dbc.getActiveDataPGSchema() + "." + XMI_NS_TABLE)) {
     try (CoStoSysConnection conn = dbc.obtainOrReserveConnection()){
      conn.setAutoCommit(true);
      Statement stmt = conn.createStatement();
      String sql = String.format("CREATE TABLE %s (%s text PRIMARY KEY, %s text)", dbc.getActiveDataPGSchema() + "." + XMI_NS_TABLE, PREFIX, NS_URI);
      stmt.execute(sql);
    } catch (SQLException e) {
      e.printStackTrace();
      SQLException ne = e.getNextException();
      if (null != ne)
        ne.printStackTrace();
    }
  }
}
origin: de.julielab/jcore-xmi-db-writer

obsoleteAnnotationTables = new ArrayList<>();
try (CoStoSysConnection conn = dbc.obtainOrReserveConnection()){
  Statement stmt = conn.createStatement();
  ResultSet rs = stmt.executeQuery("SELECT " + TABLE_NAME + " FROM " + dbc.getActiveDataPGSchema() + "." + ANNOTATION_LIST_TABLE);
origin: de.julielab/jcore-xmi-db-reader

private Map<String, String> getNamespaceMap() {
  Map<String, String> map = null;
  if (dbc.tableExists(dbc.getActiveDataPGSchema() + "." + XmiSplitConstants.XMI_NS_TABLE)) {
    try (CoStoSysConnection conn = dbc.obtainOrReserveConnection()){
      map = new HashMap<>();
      conn.setAutoCommit(true);
      Statement stmt = conn.createStatement();
      String sql = String.format("SELECT %s,%s FROM %s", XmiSplitConstants.PREFIX, XmiSplitConstants.NS_URI,
          dbc.getActiveDataPGSchema() + "." + XmiSplitConstants.XMI_NS_TABLE);
      ResultSet rs = stmt.executeQuery(String.format(sql));
      while (rs.next())
        map.put(rs.getString(1), rs.getString(2));
    } catch (SQLException e) {
      e.printStackTrace();
      SQLException ne = e.getNextException();
      if (null != ne)
        ne.printStackTrace();
    }
  } else {
    log.warn(
        "Table \"{}\" was not found it is assumed that the table from which is read contains complete XMI documents.",
        dbc.getActiveDataPGSchema() + "." + XmiSplitConstants.XMI_NS_TABLE);
  }
  return map;
}
origin: de.julielab/jcore-xmi-db-writer

  private void createAnnotationListTable() {
    if (!dbc.tableExists(dbc.getActiveDataPGSchema() + "." + ANNOTATION_LIST_TABLE)) {
      try (CoStoSysConnection conn = dbc.obtainOrReserveConnection()){
        conn.setAutoCommit(true);
        Statement stmt = conn.createStatement();
        String sql = String.format("CREATE TABLE %s (%s text PRIMARY KEY)",
            dbc.getActiveDataPGSchema() + "." + ANNOTATION_LIST_TABLE, TABLE_NAME);
        stmt.execute(sql);
      } catch (SQLException e) {
        e.printStackTrace();
        SQLException ne = e.getNextException();
        if (null != ne)
          ne.printStackTrace();
      }
    }
  }
}
origin: de.julielab/jcore-xmi-db-reader

try (CoStoSysConnection conn = dbc.obtainOrReserveConnection()) {
  nsAndXmiVersion = getNamespaceMap();
origin: de.julielab/jcore-db-reader

try (CoStoSysConnection ignored = dbc.obtainOrReserveConnection()) {
  ids = dbc.retrieveAndMark(tableName, getReaderComponentName(), hostName, pid, limit, selectionOrder);
origin: de.julielab/jcore-xmi-db-writer

try  (CoStoSysConnection conn = dbc.obtainOrReserveConnection()){
  conn.setAutoCommit(false);
  for (String tableName : serializedCASes.keySet()) {
origin: de.julielab/jcore-db-reader

if (batchSize == 0)
  log.warn("Batch size of retrieved documents is set to 0. Nothing will be returned.");
try (CoStoSysConnection conn = dbc.obtainOrReserveConnection()) {
  if (resetTable)
    dbc.resetSubset(tableName);
origin: de.julielab/jcore-xmi-db-reader

  throw new ResourceInitializationException(e);
try (CoStoSysConnection ignored = dbc.obtainOrReserveConnection()) {
  List<Map<String, String>> primaryKeyFields = dbc.getActiveTableFieldConfiguration().getPrimaryKeyFields().collect(Collectors.toList());
  if (rowBatch.getReadsBaseXmiDocument()) {
origin: de.julielab/jcore-xmi-db-reader

  throw new ResourceInitializationException(e);
try (CoStoSysConnection conn = dbc.obtainOrReserveConnection()) {
  List<Map<String, String>> primaryKeyFields = dbc.getActiveTableFieldConfiguration().getPrimaryKeyFields().collect(Collectors.toList());
  if ((Boolean) getConfigParameterValue(PARAM_READS_BASE_DOCUMENT)) {
origin: de.julielab/jcore-xmi-db-reader

  throw new ResourceInitializationException(e);
try (CoStoSysConnection conn = dbc.obtainOrReserveConnection()) {
  List<Map<String, String>> primaryKeyFields = dbc.getActiveTableFieldConfiguration().getPrimaryKeyFields().collect(Collectors.toList());
  if ((Boolean) getConfigParameterValue(PARAM_READS_BASE_DOCUMENT)) {
de.julielab.xmlData.dataBaseDataBaseConnectorobtainOrReserveConnection

Popular methods of DataBaseConnector

  • <init>
  • checkTableDefinition
  • getActiveDataPGSchema
  • getFieldConfiguration
  • tableExists
  • addXmiAnnotationFieldConfiguration
  • addXmiDocumentFieldConfiguration
  • addXmiTextFieldConfiguration
  • close
  • getActiveTableFieldConfiguration
  • getNextOrThisDataTable
  • getPrimaryKeyIndices
  • getNextOrThisDataTable,
  • getPrimaryKeyIndices,
  • isDataTable,
  • releaseConnections,
  • reserveConnection,
  • checkTableSchemaCompatibility,
  • countRowsOfDataTable,
  • countUnprocessed,
  • createSchema

Popular in Java

  • Running tasks concurrently on multiple threads
  • onRequestPermissionsResult (Fragment)
  • scheduleAtFixedRate (ScheduledExecutorService)
  • getContentResolver (Context)
  • FileInputStream (java.io)
    An input stream that reads bytes from a file. File file = ...finally if (in != null) in.clos
  • TimerTask (java.util)
    The TimerTask class represents a task to run at a specified time. The task may be run once or repeat
  • JFileChooser (javax.swing)
  • Options (org.apache.commons.cli)
    Main entry-point into the library. Options represents a collection of Option objects, which describ
  • IsNull (org.hamcrest.core)
    Is the value null?
  • Join (org.hibernate.mapping)
  • Github Copilot alternatives
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now