Exemplo n.º 1
0
  public Connection get_connection() {
    try {
      // This will load the MySQL driver, each DB has its own driver
      Class.forName("com.mysql.jdbc.Driver");

      // Setup the connection with the DB
      Connection connect =
          DriverManager.getConnection(
              "jdbc:mysql://"
                  + Non_GUI_config.get_database_host()
                  + "/"
                  + Non_GUI_config.get_database_name()
                  + "?"
                  + "user="******"&password="
                  + Non_GUI_config.get_database_password());

      return connect;
    } catch (SQLException ex) {
      System.out.println(ex);
      return null;
    } catch (ClassNotFoundException ex) {
      System.out.println(ex);
      return null;
    }
  }
Exemplo n.º 2
0
  public ResultSet get_parsing_entity() {

    Connection connect = get_connection();

    if (connect != null) {

      try {
        PreparedStatement prepared_statement =
            connect.prepareStatement(
                "SELECT * FROM " + Non_GUI_config.get_database_name() + ".parsing_entity");

        ResultSet cat = prepared_statement.executeQuery();

        while (cat.next()) {
          System.out.println(cat.getString("starting_url"));
          System.out.println(cat.getString("domain"));
        }

        System.out.println("here");
      } catch (SQLException ex) {
        return null;
      }
    }

    return null;
  }