<commit_before>package jp.co.ixui.tamura;

import java.net.URI;
import java.net.URISyntaxException;

import javax.sql.DataSource;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.jdbc.DataSourceBuilder;
import org.springframework.boot.autoconfigure.jdbc.DataSourceProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Primary;

/**
 * @author tamura
 *
 */
@Configuration
public class DatabaseConfig {
	@Autowired
	DataSourceProperties properties;

	@Primary
	@Bean(destroyMethod="close")
	DataSource datasource() throws URISyntaxException {
		String url;
		String userName;
		String password;

		String databaseUrl = System.getenv("DATABASE_URL");
		if (null != databaseUrl) {
			//heroku
			URI dbUri = new URI(databaseUrl);
			url = "jdbc:mysql://" + dbUri.getHost() + dbUri.getPath();
			userName = dbUri.getUserInfo().split(":")[0];
			password = dbUri.getUserInfo().split(":")[1];
		} else {
			//localhost
			url = this.properties.getUrl();
			userName = this.properties.getUsername();
			password = this.properties.getPassword();
		}

		DataSourceBuilder factory = DataSourceBuilder
				.create(this.properties.getClassLoader())
				.url(url)
				.username(userName)
				.password(password);
		return factory.build();
	}
}
<commit_msg>再接続設定を追加 ※ 一部で非推奨という話があるが、まずはHeroku側の設定に合わせる<commit_after>package jp.co.ixui.tamura;

import java.net.URI;
import java.net.URISyntaxException;

import javax.sql.DataSource;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.jdbc.DataSourceBuilder;
import org.springframework.boot.autoconfigure.jdbc.DataSourceProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Primary;

/**
 * @author tamura
 *
 */
@Configuration
public class DatabaseConfig {
	@Autowired
	DataSourceProperties properties;

	@Primary
	@Bean(destroyMethod="close")
	DataSource datasource() throws URISyntaxException {
		String url;
		String userName;
		String password;

		String databaseUrl = System.getenv("DATABASE_URL");
		if (null != databaseUrl) {
			//heroku
			URI dbUri = new URI(databaseUrl);
			url = "jdbc:mysql://" + dbUri.getHost() + dbUri.getPath() + "?reconnect=true";
			userName = dbUri.getUserInfo().split(":")[0];
			password = dbUri.getUserInfo().split(":")[1];
		} else {
			//localhost
			url = this.properties.getUrl();
			userName = this.properties.getUsername();
			password = <PASSWORD>();
		}

		DataSourceBuilder factory = DataSourceBuilder
				.create(this.properties.getClassLoader())
				.url(url)
				.username(userName)
				.password(password);
		return factory.build();
	}
}

{'fraction_non_alphanumeric': 0.12830319888734354, 'fraction_numerical': 0.0013908205841446453, 'mean_word_length': 4.907597535934292, 'pattern_counts': {'":': 4, '<': 4, '<?xml version=': 0, '>': 4, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, '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': '3102569', 'n_tokens_mistral': 979, 'n_tokens_neox': 893, 'n_words': 157}