コード例 #1
0
 /**
  * Checks if a lock is left behind in the DB.
  *
  * @param con
  * @param conID
  * @return true if a lock is found.
  */
 public static boolean checkLocks(Connection connection, long conID) {
   try {
     Statement stmt = connection.createStatement();
     ResultSet res = stmt.executeQuery("exec sa_locks " + conID);
     while (res.next()) {
       return true;
     }
   } catch (SQLException ex) {
     logger.error("Unable to retrieve connection ID", ex);
   }
   return false;
 }
コード例 #2
0
  /**
   * Gets the ConnectionID attribute of the SybaseConnector class
   *
   * @param connection
   * @return The ConnectionID value
   */
  public static long getConnectionID(Connection connection) {
    try {
      Statement stmt = connection.createStatement();
      ResultSet res = stmt.executeQuery("select connection_property('Number')");
      res.next();
      return res.getLong(1);
    } catch (SQLException ex) {
      logger.error("SQL exception retrieving connection ID:" + ex.getMessage());
    }

    return InvalidConnectionId;
  }