<commit_before>package com.j256.ormlite.jdbc;

import java.sql.Connection;
import java.sql.DatabaseMetaData;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Savepoint;
import java.sql.Statement;

import com.j256.ormlite.field.DataType;
import com.j256.ormlite.field.SqlType;
import com.j256.ormlite.stmt.GenericRowMapper;
import com.j256.ormlite.support.DatabaseConnection;
import com.j256.ormlite.support.GeneratedKeyHolder;
import com.j256.ormlite.support.PreparedStmt;
import com.j256.ormlite.support.Results;

public class JdbcDatabaseConnection implements DatabaseConnection {

	private static Object[] noArgs = new Object[0];
	private static SqlType[] noArgTypes = new SqlType[0];
	private static GenericRowMapper<Long> longWrapper = new OneLongWrapper();

	private Connection connection;
	private DatabaseMetaData metaData = null;

	public JdbcDatabaseConnection(Connection connection) {
		this.connection = connection;
	}

	public boolean isSupportsSavepoints() throws SQLException {
		if (metaData == null) {
			metaData = connection.getMetaData();
		}
		return metaData.supportsSavepoints();
	}

	public boolean getAutoCommit() throws SQLException {
		return connection.getAutoCommit();
	}

	public void setAutoCommit(boolean autoCommit) throws SQLException {
		connection.setAutoCommit(autoCommit);
	}

	public Savepoint setSavepoint(String name) throws SQLException {
		return connection.setSavepoint(name);
	}

	public void commit() throws SQLException {
		connection.commit();
	}

	public void releaseSavepoint(Savepoint savepoint) throws SQLException {
		connection.releaseSavepoint(savepoint);
	}

	public void rollback() throws SQLException {
		connection.rollback();
	}

	public void rollback(Savepoint savepoint) throws SQLException {
		connection.rollback(savepoint);
	}

	public PreparedStmt prepareStatement(String sql) throws SQLException {
		return new JdbcPreparedStmt(connection.prepareStatement(sql));
	}

	public void close() throws SQLException {
		connection.close();
	}

	/**
	 * Returns whether the connection has already been closed. Used by {@link JdbcConnectionSource}.
	 */
	boolean isClosed() throws SQLException {
		return connection.isClosed();
	}

	public int insert(String statement, Object[] args, SqlType[] argFieldTypes) throws SQLException {
		// it's a call to executeUpdate
		return update(statement, args, argFieldTypes);
	}

	public int insert(String statement, Object[] args, SqlType[] argFieldTypes, GeneratedKeyHolder keyHolder)
			throws SQLException {
		PreparedStatement stmt = connection.prepareStatement(statement, Statement.RETURN_GENERATED_KEYS);
		statementSetArgs(stmt, args, argFieldTypes);
		int rowN = stmt.executeUpdate();
		JdbcResults results = new JdbcResults(stmt, stmt.getGeneratedKeys());
		if (results == null) {
			// may never happen but let's be careful
			throw new SQLException("No generated key results returned from update: " + statement);
		}
		int colN = results.getColumnCount();
		while (results.next()) {
			for (int colC = 1; colC <= colN; colC++) {
				String colName = results.getColumnName(colC);
				DataType dataType = results.getColumnDataType(colC);
				Number id = dataType.resultToId(results, colC);
				if (id == null) {
					// may never happen but let's be careful
					throw new SQLException("Generated column " + colName + " is invalid type " + dataType);
				} else {
					keyHolder.addKey(id);
				}
			}
		}
		return rowN;
	}

	public int update(String statement, Object[] args, SqlType[] argFieldTypes) throws SQLException {
		PreparedStatement stmt = connection.prepareStatement(statement);
		statementSetArgs(stmt, args, argFieldTypes);
		return stmt.executeUpdate();
	}

	public int delete(String statement, Object[] args, SqlType[] argFieldTypes) throws SQLException {<commit_msg>Moved a column name within the if.<commit_after>package com.j256.ormlite.jdbc;

import java.sql.Connection;
import java.sql.DatabaseMetaData;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Savepoint;
import java.sql.Statement;

import com.j256.ormlite.field.DataType;
import com.j256.ormlite.field.SqlType;
import com.j256.ormlite.stmt.GenericRowMapper;
import com.j256.ormlite.support.DatabaseConnection;
import com.j256.ormlite.support.GeneratedKeyHolder;
import com.j256.ormlite.support.PreparedStmt;
import com.j256.ormlite.support.Results;

public class JdbcDatabaseConnection implements DatabaseConnection {

	private static Object[] noArgs = new Object[0];
	private static SqlType[] noArgTypes = new SqlType[0];
	private static GenericRowMapper<Long> longWrapper = new OneLongWrapper();

	private Connection connection;
	private DatabaseMetaData metaData = null;

	public JdbcDatabaseConnection(Connection connection) {
		this.connection = connection;
	}

	public boolean isSupportsSavepoints() throws SQLException {
		if (metaData == null) {
			metaData = connection.getMetaData();
		}
		return metaData.supportsSavepoints();
	}

	public boolean getAutoCommit() throws SQLException {
		return connection.getAutoCommit();
	}

	public void setAutoCommit(boolean autoCommit) throws SQLException {
		connection.setAutoCommit(autoCommit);
	}

	public Savepoint setSavepoint(String name) throws SQLException {
		return connection.setSavepoint(name);
	}

	public void commit() throws SQLException {
		connection.commit();
	}

	public void releaseSavepoint(Savepoint savepoint) throws SQLException {
		connection.releaseSavepoint(savepoint);
	}

	public void rollback() throws SQLException {
		connection.rollback();
	}

	public void rollback(Savepoint savepoint) throws SQLException {
		connection.rollback(savepoint);
	}

	public PreparedStmt prepareStatement(String sql) throws SQLException {
		return new JdbcPreparedStmt(connection.prepareStatement(sql));
	}

	public void close() throws SQLException {
		connection.close();
	}

	/**
	 * Returns whether the connection has already been closed. Used by {@link JdbcConnectionSource}.
	 */
	boolean isClosed() throws SQLException {
		return connection.isClosed();
	}

	public int insert(String statement, Object[] args, SqlType[] argFieldTypes) throws SQLException {
		// it's a call to executeUpdate
		return update(statement, args, argFieldTypes);
	}

	public int insert(String statement, Object[] args, SqlType[] argFieldTypes, GeneratedKeyHolder keyHolder)
			throws SQLException {
		PreparedStatement stmt = connection.prepareStatement(statement, Statement.RETURN_GENERATED_KEYS);
		statementSetArgs(stmt, args, argFieldTypes);
		int rowN = stmt.executeUpdate();
		JdbcResults results = new JdbcResults(stmt, stmt.getGeneratedKeys());
		if (results == null) {
			// may never happen but let's be careful
			throw new SQLException("No generated key results returned from update: " + statement);
		}
		int colN = results.getColumnCount();
		while (results.next()) {
			for (int colC = 1; colC <= colN; colC++) {
				DataType dataType = results.getColumnDataType(colC);
				Number id = dataType.resultToId(results, colC);
				if (id == null) {
					// may never happen but let's be careful
					String colName = results.getColumnName(colC);
					throw new SQLException("Generated column " + colName + " is invalid type " + dataType);
				} else {
					keyHolder.addKey(id);
				}
			}
		}
		return rowN;
	}

	public int update(String statement, Object[] args, SqlType[] argFieldTypes) throws SQLException {
		PreparedStatement stmt = connection.prepareStatement(statement);
		statementSetArgs(stmt, args, argFieldTypes);
		return stmt.executeUpdate();
	}

	public int delete(String statement, Object[] args, SqlType[] argFieldTypes) throws SQLException {
{'fraction_non_alphanumeric': 0.09655261793675479, 'fraction_numerical': 0.006998444790046656, 'mean_word_length': 5.081166272655635, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 5, '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': '3227092', 'n_tokens_mistral': 2403, 'n_tokens_neox': 2185, 'n_words': 600}