コード例 #1
0
  /**
   * Initializes the sql query environment from the SqlResources file. Will look for
   * conf/sqlResources.xml.
   *
   * @param conn The connection for accessing the database
   * @param sqlFileUrl The url which we use to get the sql file
   * @throws Exception If any error occurs
   */
  private void initSqlQueries(Connection conn, String sqlFileUrl) throws Exception {
    try {

      File sqlFile;

      try {
        sqlFile = fileSystem.getFile(sqlFileUrl);
        sqlFileUrl = null;
      } catch (Exception e) {
        serviceLog.error(e.getMessage(), e);
        throw e;
      }

      sqlQueries.init(sqlFile.getCanonicalFile(), "GreyList", conn, sqlParameters);

      selectQuery = sqlQueries.getSqlString("selectQuery", true);
      insertQuery = sqlQueries.getSqlString("insertQuery", true);
      deleteQuery = sqlQueries.getSqlString("deleteQuery", true);
      deleteAutoWhiteListQuery = sqlQueries.getSqlString("deleteAutoWhitelistQuery", true);
      updateQuery = sqlQueries.getSqlString("updateQuery", true);

    } finally {
      theJDBCUtil.closeJDBCConnection(conn);
    }
  }
コード例 #2
0
  /**
   * Initializes the sql query environment from the SqlResources file. Will look for
   * conf/sqlResources.xml.
   *
   * @param conn The connection for accessing the database
   * @param mailetContext The current mailet context, for finding the conf/sqlResources.xml file
   * @throws Exception If any error occurs
   */
  private void initSqlQueries(Connection conn, org.apache.mailet.MailetContext mailetContext)
      throws Exception {
    try {
      if (conn.getAutoCommit()) {
        conn.setAutoCommit(false);
      }

      /*
       Holds value of property sqlFile.
      */
      File sqlFile =
          new File((String) mailetContext.getAttribute("confDir"), "sqlResources.xml")
              .getCanonicalFile();
      sqlQueries.init(sqlFile, "WhiteList", conn, getSqlParameters());

      checkTables(conn);
    } finally {
      theJDBCUtil.closeJDBCConnection(conn);
    }
  }