org.apache.ibatis.jdbc.SqlRunner Maven / Gradle / Ivy
package org.apache.ibatis.jdbc;
import org.apache.ibatis.type.TypeHandler;
import org.apache.ibatis.type.TypeHandlerRegistry;
import org.apache.ibatis.io.Resources;
import java.sql.*;
import java.util.*;
public class SqlRunner {
public static final int NO_GENERATED_KEY = Integer.MIN_VALUE + 1001;
private Connection connection;
private TypeHandlerRegistry typeHandlerRegistry;
private boolean useGeneratedKeySupport;
public SqlRunner(Connection connection) {
this.connection = connection;
this.typeHandlerRegistry = new TypeHandlerRegistry();
}
public void setUseGeneratedKeySupport(boolean useGeneratedKeySupport) {
this.useGeneratedKeySupport = useGeneratedKeySupport;
}
/**
* Executes a SELECT statement that returns one row.
*
* @param sql The SQL
* @param args The arguments to be set on the statement.
* @return The number of rows impacted or BATCHED_RESULTS if the statements are being batched.
* @throws SQLException If more than one row is returned
*/
public Map selectOne(String sql, Object... args) throws SQLException {
List