<commit_before>/*
 * Copyright 2002-2014 the original author or authors.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package com.example;

import com.example.database.DatabaseConfig;
import com.example.util.Logger;
import com.zaxxer.hikari.HikariConfig;
import com.zaxxer.hikari.HikariDataSource;

import org.apache.commons.dbcp.BasicDataSource;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.annotation.Bean;
import org.springframework.stereotype.Component;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;

import javax.annotation.PostConstruct;
import javax.sql.DataSource;

import java.net.URI;
import java.net.URISyntaxException;
import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import java.util.ArrayList;
import java.util.Map;

// TODO for page navigation and controller logic have a look at 
// https://spring.io/guides/gs/serving-web-content/
// The Main here has been jammed as a controller class
@Controller
@SpringBootApplication
public class Main {

  @Value("${spring.datasource.url}")
  private String dbUrl;

  
  private static DataSource dataSource; // autowire does not work on static sources

  @Autowired
  private DataSource dataSource2;
  
  public static void main(String[] args) throws Exception {
	Logger.log(Main.class.getName(), "calling Main Method");
    SpringApplication.run(Main.class, args);
    // TODO connecting manually to the database works fine. Need to Autowire this shiet
    //myRealMainMethod();
  
  }
  

  public static void myRealMainMethod() throws SQLException, URISyntaxException {
	  Logger.log(Main.class.getName(), "calling myRealMainMethod");
	  DatabaseConfig config = new DatabaseConfig();
	  dataSource = config.dataSource();
	  
      Statement stmt = dataSource.getConnection().createStatement();
     /* stmt.executeUpdate("DROP TABLE IF EXISTS ticks");
      stmt.executeUpdate("CREATE TABLE ticks (tick timestamp)");
      stmt.executeUpdate("INSERT INTO ticks VALUES (now())");*/
      ResultSet rs = stmt.executeQuery("select * from actor");
      while (rs.next()) {
          System.out.println("Read from DB: " + rs.getString("actor_id") + " : " +  rs.getString("first_name") + ", " + rs.getString("last_name"));
      }
  }
  
  
  // TODO test method to connect to the database
  public static void testPostgresDB() throws URISyntaxException{
	  
	  
	 /* URI dbUri = new URI(System.getenv("DATABASE_URL"));
	    String username = dbUri.getUserInfo().split(":")[0];
	    String password = dbUri.getUserInfo().split(":")[1];
	    String dbUrl = "jdbc:postgresql://" + dbUri.getHost() + dbUri.getPath();

	    Logger.log("username", username, "password", password, "dbUrl", dbUrl);*/
  }
<commit_msg>Changed Test method name<commit_after>/*
 * Copyright 2002-2014 the original author or authors.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package com.example;

import com.example.database.DatabaseConfig;
import com.example.util.Logger;
import com.zaxxer.hikari.HikariConfig;
import com.zaxxer.hikari.HikariDataSource;

import org.apache.commons.dbcp.BasicDataSource;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.annotation.Bean;
import org.springframework.stereotype.Component;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;

import javax.annotation.PostConstruct;
import javax.sql.DataSource;

import java.net.URI;
import java.net.URISyntaxException;
import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import java.util.ArrayList;
import java.util.Map;

// TODO for page navigation and controller logic have a look at 
// https://spring.io/guides/gs/serving-web-content/
// The Main here has been jammed as a controller class
@Controller
@SpringBootApplication
public class Main {

  @Value("${spring.datasource.url}")
  private String dbUrl;

  
  private static DataSource dataSource; // autowire does not work on static sources

  @Autowired
  private DataSource dataSource2;
  
  public static void main(String[] args) throws Exception {
	Logger.log(Main.class.getName(), "calling Main Method");
    SpringApplication.run(Main.class, args);
    // TODO connecting manually to the database works fine. Need to Autowire this shiet
    //testingDatabaseConnection();
  
  }
  

  public static void testingDatabaseConnection() throws SQLException, URISyntaxException {
	  Logger.log(Main.class.getName(), "calling testingDatabaseConnection");
	  DatabaseConfig config = new DatabaseConfig();
	  dataSource = config.dataSource();
	  
      Statement stmt = dataSource.getConnection().createStatement();
     /* stmt.executeUpdate("DROP TABLE IF EXISTS ticks");
      stmt.executeUpdate("CREATE TABLE ticks (tick timestamp)");
      stmt.executeUpdate("INSERT INTO ticks VALUES (now())");*/
      ResultSet rs = stmt.executeQuery("select * from actor");
      while (rs.next()) {
          System.out.println("Read from DB: " + rs.getString("actor_id") + " : " +  rs.getString("first_name") + ", " + rs.getString("last_name"));
      }
  }
  
  
  // TODO test method to connect to the database
  public static void testPostgresDB() throws URISyntaxException{
	  
	  
	 /* URI dbUri = new URI(System.getenv("DATABASE_URL"));
	    String username = dbUri.getUserInfo().split(":")[0];
	    String password = dbUri.getUserInfo().split(":")[1];
	    String dbUrl = "jdbc:postgresql://" + dbUri.getHost() + dbUri.getPath();

	    Logger.log("username", username, "password", password, "dbUrl", dbUrl);*/
  }

{'fraction_non_alphanumeric': 0.10970819304152638, 'fraction_numerical': 0.004208754208754209, 'mean_word_length': 4.320149253731343, 'pattern_counts': {'":': 4, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 2, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2997663', 'n_tokens_mistral': 2031, 'n_tokens_neox': 1968, 'n_words': 581}