<commit_before>package com.msgsystems.training.w03d04.repository;

import com.msgsystems.training.w03d04.model.Product;

import java.io.InputStream;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import java.util.Properties;

public class ProductRepository {

    private static final String DB_PROPERTIES_FILE = "database-connection.properties";
    private static String DB_URL;
    private static String DB_USER;
    private static String DB_PASS;

    static {
        final ClassLoader contextClassLoader = Thread.currentThread().getContextClassLoader();
        try (final InputStream inputStream = contextClassLoader.getResourceAsStream(DB_PROPERTIES_FILE)) {
            final Properties properties = new Properties();
            properties.load(inputStream);

            DB_URL = properties.getProperty("database.url");
            DB_USER = properties.getProperty("database.user");
            DB_PASS = properties.getProperty("database.pass");
        } catch (Exception ex) {
            ex.printStackTrace();
        }
    }

    public int getCount() {
        Connection connection = null;
        ResultSet resultSet = null;
        Statement statement = null;

        try {
            connection = getConnection();
            statement = connection.createStatement();

            resultSet = statement.executeQuery("SELECT count(*) FROM Product");
            resultSet.next();
            return resultSet.getInt(1);
        } catch (final SQLException ex) {
            throw new IllegalArgumentException(ex.getMessage());
        } finally {
            closeResources(connection, resultSet, statement);<commit_msg>[dev] Added an UPDATE sample<commit_after>package com.msgsystems.training.w03d04.repository;

import com.msgsystems.training.w03d04.model.Product;

import java.io.InputStream;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import java.util.Properties;

public class ProductRepository {

    private static final String DB_PROPERTIES_FILE = "database-connection.properties";
    private static String DB_URL;
    private static String DB_USER;
    private static String DB_PASS;

    static {
        final ClassLoader contextClassLoader = Thread.currentThread().getContextClassLoader();
        try (final InputStream inputStream = contextClassLoader.getResourceAsStream(DB_PROPERTIES_FILE)) {
            final Properties properties = new Properties();
            properties.load(inputStream);

            DB_URL = properties.getProperty("database.url");
            DB_USER = properties.getProperty("database.user");
            DB_PASS = properties.getProperty("database.pass");
        } catch (Exception ex) {
            ex.printStackTrace();
        }
    }

    public int getCount() {
        Connection connection = null;
        ResultSet resultSet = null;
        Statement statement = null;

        try {
            connection = getConnection();
            statement = connection.createStatement();

            resultSet = statement.executeQuery("SELECT count(*) FROM Product");
            resultSet.next();
            return resultSet.getInt(1);
        } catch (final SQLException ex) {
            throw new IllegalArgumentException(ex.getMessage());
        } finally {
            closeResources(connection, resultSet, statement);
        }
    }

    public boolean updateProductSection(int oldSectionId, int newSectionId) {
        Connection connection = null;
        ResultSet resultSet = null;
        Statement statement = null;

        try {
            connection = getConnection();
            statement = connection.createStatement();

            final String sql = "UPDATE Product SET sectionId = " + newSectionId + " WHERE sectionId = " + oldSectionId;
            int updatedRecords = statement.executeUpdate(sql);
            System.out.println("There were " + updatedRecords + " products moved from section " + oldSectionId + " to section " + newSectionId);
            return updatedRecords > 0;
        } catch (final SQLException ex) {
            throw new IllegalArgumentException(ex.getMessage());
        } finally {
            closeResources(connection, resultSet, statement);
{'fraction_non_alphanumeric': 0.08917927556166896, 'fraction_numerical': 0.004355800091701055, 'mean_word_length': 2.8071553228621293, 'pattern_counts': {'":': 0, '<': 3, '<?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': '1468227', 'n_tokens_mistral': 1059, 'n_tokens_neox': 1035, 'n_words': 264}