code: private List<Metric> checkTablespace(final Connection c, final ICommandLine cl) throws BadThresholdException, SQLException {
  
          // Metric : tblspace_usage
  
          List<Metric> metricList = new ArrayList<Metric>();
  
          String sTablespace = cl.getOptionValue("tablespace").toUpperCase();
  
          // FIXME : a prepared satement should be used
          final String sQry = String.format(QRY_CHECK_TBLSPACE_PATTERN, sTablespace);
          Statement stmt = null;
          ResultSet rs = null;
  
          try {
              stmt = c.createStatement();
  
              rs = stmt.executeQuery(sQry);
  
              boolean bFound = rs.next();
  
              if (!bFound) {
                  throw new SQLException("Tablespace " + cl.getOptionValue("tablespace") + " not found.");
              }
  
              BigDecimal tsFree = rs.getBigDecimal(1);
              BigDecimal tsTotal = rs.getBigDecimal(2);
              BigDecimal tsPct = rs.getBigDecimal(3);
              //
              metricList.add(new Metric("tblspace_freepct", cl.getOptionValue("tablespace") + " : " + tsPct + "% free", tsPct, new BigDecimal(0),
                      new BigDecimal(100)));
  
              metricList.add(new Metric("tblspace_free", cl.getOptionValue("tablespace") + " : " + tsFree + "MB free", tsPct, new BigDecimal(0),
                      tsTotal));
  
              return metricList;
  
          } finally {
              DBUtils.closeQuietly(rs);
              DBUtils.closeQuietly(stmt);
          }
  
      }
docs: Checks database usage.
  
  @param c
  The connection to the database
  @param cl
  The command line as received from JNRPE
  @return The plugin result
  @throws BadThresholdException
  -