Class Yank

java.lang.Object
org.knowm.yank.Yank

public class Yank extends Object
A wrapper for DBUtils' QueryRunner's methods: update, query, and batch. Connections are retrieved from the connection pool in DBConnectionManager.
Author:
timmolter
  • Method Summary

    Modifier and Type
    Method
    Description
    static void
    Add SQL statements in a properties file.
    static int
    execute(String sql, Object[] params)
    Executes the given INSERT, UPDATE, DELETE, REPLACE or UPSERT SQL prepared statement.
    static int
    execute(String poolName, String sql, Object[] params)
    Executes the given INSERT, UPDATE, DELETE, REPLACE or UPSERT SQL prepared statement.
    static int[]
    executeBatch(String sql, Object[][] params)
    Batch executes the given INSERT, UPDATE, DELETE, REPLACE or UPSERT SQL statement using the default connection pool.
    static int[]
    executeBatch(String poolName, String sql, Object[][] params)
    Batch executes the given INSERT, UPDATE, DELETE, REPLACE or UPSERT SQL statement
    static int[]
    executeBatchSQLKey(String sqlKey, Object[][] params)
    Batch executes the given INSERT, UPDATE, DELETE, REPLACE or UPSERT SQL statement matching the sqlKey String in a properties file loaded via Yank.addSQLStatements(...) using the default connection pool.
    static int[]
    executeBatchSQLKey(String poolName, String sqlKey, Object[][] params)
    Batch executes the given INSERT, UPDATE, DELETE, REPLACE or UPSERT SQL statement matching the sqlKey String in a properties file loaded via Yank.addSQLStatements(...).
    static int
    executeSQLKey(String sqlKey, Object[] params)
    Executes the given INSERT, UPDATE, DELETE, REPLACE or UPSERT SQL statement matching the sqlKey String in a properties file loaded via Yank.addSQLStatements(...) using the default connection pool.
    static int
    executeSQLKey(String poolName, String sqlKey, Object[] params)
    Executes the given INSERT, UPDATE, DELETE, REPLACE or UPSERT SQL statement matching the sqlKey String in a properties file loaded via Yank.addSQLStatements(...).
    static com.zaxxer.hikari.HikariDataSource
    Exposes access to the configured connection pool
    static com.zaxxer.hikari.HikariDataSource
    Exposes access to the default connection pool.
    static Long
    insert(String sql, Object[] params)
    Executes a given INSERT SQL prepared statement.
    static Long
    insert(String poolName, String sql, Object[] params)
    Executes a given INSERT SQL prepared statement.
    static Long
    insertSQLKey(String sqlKey, Object[] params)
    Executes a given INSERT SQL prepared statement matching the sqlKey String in a properties file loaded via Yank.addSQLStatements(...) using the default connection pool.
    static Long
    insertSQLKey(String poolName, String sqlKey, Object[] params)
    Executes a given INSERT SQL prepared statement matching the sqlKey String in a properties file loaded via Yank.addSQLStatements(...).
    static boolean
     
    static <T> T
    queryBean(String sql, Class<T> beanType, Object[] params)
    Return just one Bean given an SQL statement.
    static <T> T
    queryBean(String poolName, String sql, Class<T> beanType, Object[] params)
    Return just one Bean given an SQL statement.
    static <T> List<T>
    queryBeanList(String sql, Class<T> beanType, Object[] params)
    Return a List of Beans given an SQL statement using the default connection pool.
    static <T> List<T>
    queryBeanList(String poolName, String sql, Class<T> beanType, Object[] params)
    Return a List of Beans given an SQL statement
    static <T> List<T>
    queryBeanListSQLKey(String sqlKey, Class<T> beanType, Object[] params)
    Return a List of Beans given a SQL Key using an SQL statement matching the sqlKey String in a properties file loaded via Yank.addSQLStatements(...) using the default connection pool.
    static <T> List<T>
    queryBeanListSQLKey(String poolName, String sqlKey, Class<T> beanType, Object[] params)
    Return a List of Beans given a SQL Key using an SQL statement matching the sqlKey String in a properties file loaded via Yank.addSQLStatements(...).
    static <T> T
    queryBeanSQLKey(String sqlKey, Class<T> beanType, Object[] params)
    Return just one Bean given a SQL Key using an SQL statement matching the sqlKey String in a properties file loaded via Yank.addSQLStatements(...).
    static <T> T
    queryBeanSQLKey(String poolName, String sqlKey, Class<T> beanType, Object[] params)
    Return just one Bean given a SQL Key using an SQL statement matching the sqlKey String in a properties file loaded via Yank.addSQLStatements(...).
    static <T> List<T>
    queryColumn(String sql, String columnName, Class<T> columnType, Object[] params)
    Return a List of Objects from a single table column given an SQL statement using the default connection pool.
    static <T> List<T>
    queryColumn(String poolName, String sql, String columnName, Class<T> columnType, Object[] params)
    Return a List of Objects from a single table column given an SQL statement
    static <T> List<T>
    queryColumnSQLKey(String sqlKey, String columnName, Class<T> columnType, Object[] params)
    Return a List of Objects from a single table column given a SQL Key using an SQL statement matching the sqlKey String in a properties file loaded via Yank.addSQLStatements(...) using the default connection pool.
    static <T> List<T>
    queryColumnSQLKey(String poolName, String sqlKey, String columnName, Class<T> columnType, Object[] params)
    Return a List of Objects from a single table column given a SQL Key using an SQL statement matching the sqlKey String in a properties file loaded via Yank.addSQLStatements(...).
    static List<Object[]>
    Return a List of generic Object[]s given an SQL statement using the default connection pool.
    static List<Object[]>
    queryObjectArrays(String poolName, String sql, Object[] params)
    Return a List of generic Object[]s given an SQL statement
    static List<Object[]>
    Return a List of generic Object[]s given a SQL Key using an SQL statement matching the sqlKey String in a properties file loaded via Yank.addSQLStatements(...) using the default connection pool.
    static List<Object[]>
    queryObjectArraysSQLKey(String poolName, String sqlKey, Object[] params)
    Return a List of generic Object[]s given a SQL Key using an SQL statement matching the sqlKey String in a properties file loaded via Yank.addSQLStatements(...).
    static <T> T
    queryScalar(String sql, Class<T> scalarType, Object[] params)
    Return just one scalar given a an SQL statement using the default connection pool.
    static <T> T
    queryScalar(String poolName, String sql, Class<T> scalarType, Object[] params)
    Return just one scalar given a an SQL statement
    static <T> T
    queryScalarSQLKey(String sqlKey, Class<T> scalarType, Object[] params)
    Return just one scalar given a SQL Key using an SQL statement matching the sqlKey String in a properties file loaded via Yank.addSQLStatements(...) using the default connection pool.
    static <T> T
    queryScalarSQLKey(String poolName, String sqlKey, Class<T> scalarType, Object[] params)
    Return just one scalar given a SQL Key using an SQL statement matching the sqlKey String in a properties file loaded via Yank.addSQLStatements(...).
    static void
    Closes all connection pools
    static void
    Closes the given connection pool
    static void
    Closes the default connection pool
    static void
    setThrowWrappedExceptions(boolean throwWrappedExceptions)
    Set true if you want methods in "Yank" to throw unchecked `YankSQLException`s, which wrap checked `SQLException`s.
    static void
    setupConnectionPool(String poolName, Properties dataSourceProperties)
    Add properties for a DataSource (connection pool).
    static void
    setupDefaultConnectionPool(Properties dataSourceProperties)
    Add properties for a DataSource (connection pool).

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Method Details

    • insertSQLKey

      public static Long insertSQLKey(String sqlKey, Object[] params) throws SQLStatementNotFoundException, YankSQLException
      Executes a given INSERT SQL prepared statement matching the sqlKey String in a properties file loaded via Yank.addSQLStatements(...) using the default connection pool. Returns the auto-increment id of the inserted row.
      Parameters:
      sqlKey - The SQL Key found in a properties file corresponding to the desired SQL statement value
      params - The replacement parameters
      Returns:
      the auto-increment id of the inserted row, or null if no id is available
      Throws:
      SQLStatementNotFoundException - if an SQL statement could not be found for the given sqlKey String
      YankSQLException
    • insertSQLKey

      public static Long insertSQLKey(String poolName, String sqlKey, Object[] params) throws SQLStatementNotFoundException, YankSQLException
      Executes a given INSERT SQL prepared statement matching the sqlKey String in a properties file loaded via Yank.addSQLStatements(...). Returns the auto-increment id of the inserted row.
      Parameters:
      poolName - The name of the connection pool to query against
      sqlKey - The SQL Key found in a properties file corresponding to the desired SQL statement value
      params - The replacement parameters
      Returns:
      the auto-increment id of the inserted row, or null if no id is available
      Throws:
      SQLStatementNotFoundException - if an SQL statement could not be found for the given sqlKey String
      YankSQLException
    • insert

      public static Long insert(String sql, Object[] params) throws YankSQLException
      Executes a given INSERT SQL prepared statement. Returns the auto-increment id of the inserted row using the default connection pool. Note: This only works when the auto-increment table column is in the first column in the table!
      Parameters:
      sql - The query to execute
      params - The replacement parameters
      Returns:
      the auto-increment id of the inserted row, or null if no id is available
      Throws:
      YankSQLException
    • insert

      public static Long insert(String poolName, String sql, Object[] params) throws YankSQLException
      Executes a given INSERT SQL prepared statement. Returns the auto-increment id of the inserted row. Note: This only works when the auto-increment table column is in the first column in the table!
      Parameters:
      poolName - The name of the connection pool to query against
      sql - The query to execute
      params - The replacement parameters
      Returns:
      the auto-increment id of the inserted row, or null if no id is available
      Throws:
      YankSQLException
    • executeSQLKey

      public static int executeSQLKey(String sqlKey, Object[] params) throws SQLStatementNotFoundException, YankSQLException
      Executes the given INSERT, UPDATE, DELETE, REPLACE or UPSERT SQL statement matching the sqlKey String in a properties file loaded via Yank.addSQLStatements(...) using the default connection pool. Returns the number of rows affected.
      Parameters:
      sqlKey - The SQL Key found in a properties file corresponding to the desired SQL statement value
      params - The replacement parameters
      Returns:
      The number of rows affected
      Throws:
      SQLStatementNotFoundException - if an SQL statement could not be found for the given sqlKey String
      YankSQLException
    • executeSQLKey

      public static int executeSQLKey(String poolName, String sqlKey, Object[] params) throws SQLStatementNotFoundException, YankSQLException
      Executes the given INSERT, UPDATE, DELETE, REPLACE or UPSERT SQL statement matching the sqlKey String in a properties file loaded via Yank.addSQLStatements(...). Returns the number of rows affected.
      Parameters:
      poolName - The name of the connection pool to query against
      sqlKey - The SQL Key found in a properties file corresponding to the desired SQL statement value
      params - The replacement parameters
      Returns:
      The number of rows affected
      Throws:
      SQLStatementNotFoundException - if an SQL statement could not be found for the given sqlKey String
      YankSQLException
    • execute

      public static int execute(String sql, Object[] params) throws YankSQLException
      Executes the given INSERT, UPDATE, DELETE, REPLACE or UPSERT SQL prepared statement. Returns the number of rows affected using the default connection pool.
      Parameters:
      sql - The query to execute
      params - The replacement parameters
      Returns:
      The number of rows affected
      Throws:
      YankSQLException
    • execute

      public static int execute(String poolName, String sql, Object[] params) throws YankSQLException
      Executes the given INSERT, UPDATE, DELETE, REPLACE or UPSERT SQL prepared statement. Returns the number of rows affected.
      Parameters:
      poolName - The name of the connection pool to query against
      sql - The query to execute
      params - The replacement parameters
      Returns:
      The number of rows affected
      Throws:
      YankSQLException
    • queryScalarSQLKey

      public static <T> T queryScalarSQLKey(String sqlKey, Class<T> scalarType, Object[] params) throws SQLStatementNotFoundException, YankSQLException
      Return just one scalar given a SQL Key using an SQL statement matching the sqlKey String in a properties file loaded via Yank.addSQLStatements(...) using the default connection pool. If more than one row match the query, only the first row is returned.
      Parameters:
      sqlKey - The SQL Key found in a properties file corresponding to the desired SQL statement value
      scalarType - The Class of the desired return scalar matching the table
      params - The replacement parameters
      Returns:
      The Object
      Throws:
      SQLStatementNotFoundException - if an SQL statement could not be found for the given sqlKey String
      YankSQLException
    • queryScalarSQLKey

      public static <T> T queryScalarSQLKey(String poolName, String sqlKey, Class<T> scalarType, Object[] params) throws SQLStatementNotFoundException, YankSQLException
      Return just one scalar given a SQL Key using an SQL statement matching the sqlKey String in a properties file loaded via Yank.addSQLStatements(...). If more than one row match the query, only the first row is returned.
      Parameters:
      poolName - The name of the connection pool to query against
      sqlKey - The SQL Key found in a properties file corresponding to the desired SQL statement value
      scalarType - The Class of the desired return scalar matching the table
      params - The replacement parameters
      Returns:
      The Object
      Throws:
      SQLStatementNotFoundException - if an SQL statement could not be found for the given sqlKey String
      YankSQLException
    • queryScalar

      public static <T> T queryScalar(String sql, Class<T> scalarType, Object[] params) throws SQLStatementNotFoundException, YankSQLException
      Return just one scalar given a an SQL statement using the default connection pool.
      Parameters:
      scalarType - The Class of the desired return scalar matching the table
      params - The replacement parameters
      Returns:
      The scalar Object
      Throws:
      SQLStatementNotFoundException - if an SQL statement could not be found for the given sqlKey String
      YankSQLException
    • queryScalar

      public static <T> T queryScalar(String poolName, String sql, Class<T> scalarType, Object[] params) throws SQLStatementNotFoundException, YankSQLException
      Return just one scalar given a an SQL statement
      Parameters:
      poolName - The name of the connection pool to query against
      scalarType - The Class of the desired return scalar matching the table
      params - The replacement parameters
      Returns:
      The scalar Object
      Throws:
      SQLStatementNotFoundException - if an SQL statement could not be found for the given sqlKey String
      YankSQLException
    • queryBeanSQLKey

      public static <T> T queryBeanSQLKey(String sqlKey, Class<T> beanType, Object[] params) throws SQLStatementNotFoundException, YankSQLException
      Return just one Bean given a SQL Key using an SQL statement matching the sqlKey String in a properties file loaded via Yank.addSQLStatements(...). If more than one row match the query, only the first row is returned using the default connection pool.
      Parameters:
      sqlKey - The SQL Key found in a properties file corresponding to the desired SQL statement value
      beanType - The Class of the desired return Object matching the table
      params - The replacement parameters
      Returns:
      The Object
      Throws:
      SQLStatementNotFoundException - if an SQL statement could not be found for the given sqlKey String
      YankSQLException
    • queryBeanSQLKey

      public static <T> T queryBeanSQLKey(String poolName, String sqlKey, Class<T> beanType, Object[] params) throws SQLStatementNotFoundException, YankSQLException
      Return just one Bean given a SQL Key using an SQL statement matching the sqlKey String in a properties file loaded via Yank.addSQLStatements(...). If more than one row match the query, only the first row is returned.
      Parameters:
      poolName - The name of the connection pool to query against
      sqlKey - The SQL Key found in a properties file corresponding to the desired SQL statement value
      beanType - The Class of the desired return Object matching the table
      params - The replacement parameters
      Returns:
      The Object
      Throws:
      SQLStatementNotFoundException - if an SQL statement could not be found for the given sqlKey String
      YankSQLException
    • queryBean

      public static <T> T queryBean(String sql, Class<T> beanType, Object[] params) throws YankSQLException
      Return just one Bean given an SQL statement. If more than one row match the query, only the first row is returned using the default connection pool.
      Parameters:
      sql - The SQL statement
      beanType - The Class of the desired return Object matching the table
      params - The replacement parameters
      Returns:
      The Object
      Throws:
      YankSQLException
    • queryBean

      public static <T> T queryBean(String poolName, String sql, Class<T> beanType, Object[] params) throws YankSQLException
      Return just one Bean given an SQL statement. If more than one row match the query, only the first row is returned.
      Parameters:
      poolName - The name of the connection pool to query against
      sql - The SQL statement
      beanType - The Class of the desired return Object matching the table
      params - The replacement parameters
      Returns:
      The Object
      Throws:
      YankSQLException
    • queryBeanListSQLKey

      public static <T> List<T> queryBeanListSQLKey(String sqlKey, Class<T> beanType, Object[] params) throws SQLStatementNotFoundException, YankSQLException
      Return a List of Beans given a SQL Key using an SQL statement matching the sqlKey String in a properties file loaded via Yank.addSQLStatements(...) using the default connection pool.
      Parameters:
      sqlKey - The SQL Key found in a properties file corresponding to the desired SQL statement value
      beanType - The Class of the desired return Objects matching the table
      params - The replacement parameters
      Returns:
      The List of Objects
      Throws:
      SQLStatementNotFoundException - if an SQL statement could not be found for the given sqlKey String
      YankSQLException
    • queryBeanListSQLKey

      public static <T> List<T> queryBeanListSQLKey(String poolName, String sqlKey, Class<T> beanType, Object[] params) throws SQLStatementNotFoundException, YankSQLException
      Return a List of Beans given a SQL Key using an SQL statement matching the sqlKey String in a properties file loaded via Yank.addSQLStatements(...).
      Parameters:
      poolName - The name of the connection pool to query against
      sqlKey - The SQL Key found in a properties file corresponding to the desired SQL statement value
      beanType - The Class of the desired return Objects matching the table
      params - The replacement parameters
      Returns:
      The List of Objects
      Throws:
      SQLStatementNotFoundException - if an SQL statement could not be found for the given sqlKey String
      YankSQLException
    • queryBeanList

      public static <T> List<T> queryBeanList(String sql, Class<T> beanType, Object[] params) throws YankSQLException
      Return a List of Beans given an SQL statement using the default connection pool.
      Parameters:
      sql - The SQL statement
      beanType - The Class of the desired return Objects matching the table
      params - The replacement parameters
      Returns:
      The List of Objects
      Throws:
      YankSQLException
    • queryBeanList

      public static <T> List<T> queryBeanList(String poolName, String sql, Class<T> beanType, Object[] params) throws YankSQLException
      Return a List of Beans given an SQL statement
      Parameters:
      poolName - The name of the connection pool to query against
      sql - The SQL statement
      beanType - The Class of the desired return Objects matching the table
      params - The replacement parameters
      Returns:
      The List of Objects
      Throws:
      YankSQLException
    • queryColumnSQLKey

      public static <T> List<T> queryColumnSQLKey(String sqlKey, String columnName, Class<T> columnType, Object[] params) throws SQLStatementNotFoundException, YankSQLException
      Return a List of Objects from a single table column given a SQL Key using an SQL statement matching the sqlKey String in a properties file loaded via Yank.addSQLStatements(...) using the default connection pool.
      Parameters:
      sqlKey - The SQL Key found in a properties file corresponding to the desired SQL statement value
      columnType - The Class of the desired return Objects matching the table
      params - The replacement parameters
      Returns:
      The Column as a List
      Throws:
      SQLStatementNotFoundException - if an SQL statement could not be found for the given sqlKey String
      YankSQLException
    • queryColumnSQLKey

      public static <T> List<T> queryColumnSQLKey(String poolName, String sqlKey, String columnName, Class<T> columnType, Object[] params) throws SQLStatementNotFoundException, YankSQLException
      Return a List of Objects from a single table column given a SQL Key using an SQL statement matching the sqlKey String in a properties file loaded via Yank.addSQLStatements(...).
      Parameters:
      poolName - The name of the connection pool to query against
      sqlKey - The SQL Key found in a properties file corresponding to the desired SQL statement value
      columnType - The Class of the desired return Objects matching the table
      params - The replacement parameters
      Returns:
      The Column as a List
      Throws:
      SQLStatementNotFoundException - if an SQL statement could not be found for the given sqlKey String
      YankSQLException
    • queryColumn

      public static <T> List<T> queryColumn(String sql, String columnName, Class<T> columnType, Object[] params) throws YankSQLException
      Return a List of Objects from a single table column given an SQL statement using the default connection pool.
      Type Parameters:
      T -
      Parameters:
      sql - The SQL statement
      columnType - The Class of the desired return Objects matching the table
      params - The replacement parameters
      Returns:
      The Column as a List
      Throws:
      YankSQLException
    • queryColumn

      public static <T> List<T> queryColumn(String poolName, String sql, String columnName, Class<T> columnType, Object[] params) throws YankSQLException
      Return a List of Objects from a single table column given an SQL statement
      Parameters:
      poolName - The name of the connection pool to query against
      sql - The SQL statement
      columnType - The Class of the desired return Objects matching the table
      params - The replacement parameters
      Returns:
      The Column as a List
      Throws:
      YankSQLException
    • queryObjectArraysSQLKey

      public static List<Object[]> queryObjectArraysSQLKey(String sqlKey, Object[] params) throws SQLStatementNotFoundException, YankSQLException
      Return a List of generic Object[]s given a SQL Key using an SQL statement matching the sqlKey String in a properties file loaded via Yank.addSQLStatements(...) using the default connection pool.
      Parameters:
      sqlKey - The SQL Key found in a properties file corresponding to the desired SQL statement value
      params - The replacement parameters
      Returns:
      The List of generic Object[]s
      Throws:
      SQLStatementNotFoundException - if an SQL statement could not be found for the given sqlKey String
      YankSQLException
    • queryObjectArraysSQLKey

      public static List<Object[]> queryObjectArraysSQLKey(String poolName, String sqlKey, Object[] params) throws SQLStatementNotFoundException, YankSQLException
      Return a List of generic Object[]s given a SQL Key using an SQL statement matching the sqlKey String in a properties file loaded via Yank.addSQLStatements(...).
      Parameters:
      poolName - The name of the connection pool to query against
      sqlKey - The SQL Key found in a properties file corresponding to the desired SQL statement value
      params - The replacement parameters
      Returns:
      The List of generic Object[]s
      Throws:
      SQLStatementNotFoundException - if an SQL statement could not be found for the given sqlKey String
      YankSQLException
    • queryObjectArrays

      public static List<Object[]> queryObjectArrays(String sql, Object[] params) throws YankSQLException
      Return a List of generic Object[]s given an SQL statement using the default connection pool.
      Parameters:
      sql - The SQL statement
      params - The replacement parameters
      Returns:
      The List of generic Object[]s
      Throws:
      YankSQLException
    • queryObjectArrays

      public static List<Object[]> queryObjectArrays(String poolName, String sql, Object[] params) throws YankSQLException
      Return a List of generic Object[]s given an SQL statement
      Parameters:
      poolName - The name of the connection pool to query against
      sql - The SQL statement
      params - The replacement parameters
      Returns:
      The List of generic Object[]s
      Throws:
      YankSQLException
    • executeBatchSQLKey

      public static int[] executeBatchSQLKey(String sqlKey, Object[][] params) throws SQLStatementNotFoundException, YankSQLException
      Batch executes the given INSERT, UPDATE, DELETE, REPLACE or UPSERT SQL statement matching the sqlKey String in a properties file loaded via Yank.addSQLStatements(...) using the default connection pool.
      Parameters:
      sqlKey - The SQL Key found in a properties file corresponding to the desired SQL statement value
      params - An array of query replacement parameters. Each row in this array is one set of batch replacement values
      Returns:
      The number of rows affected or each individual execution
      Throws:
      SQLStatementNotFoundException - if an SQL statement could not be found for the given sqlKey String
      YankSQLException
    • executeBatchSQLKey

      public static int[] executeBatchSQLKey(String poolName, String sqlKey, Object[][] params) throws SQLStatementNotFoundException, YankSQLException
      Batch executes the given INSERT, UPDATE, DELETE, REPLACE or UPSERT SQL statement matching the sqlKey String in a properties file loaded via Yank.addSQLStatements(...).
      Parameters:
      poolName - The name of the connection pool to query against
      sqlKey - The SQL Key found in a properties file corresponding to the desired SQL statement value
      params - An array of query replacement parameters. Each row in this array is one set of batch replacement values
      Returns:
      The number of rows affected or each individual execution
      Throws:
      SQLStatementNotFoundException - if an SQL statement could not be found for the given sqlKey String
      YankSQLException
    • executeBatch

      public static int[] executeBatch(String sql, Object[][] params) throws YankSQLException
      Batch executes the given INSERT, UPDATE, DELETE, REPLACE or UPSERT SQL statement using the default connection pool.
      Parameters:
      sql - The SQL statement
      params - An array of query replacement parameters. Each row in this array is one set of batch replacement values
      Returns:
      The number of rows affected or each individual execution
      Throws:
      YankSQLException
    • executeBatch

      public static int[] executeBatch(String poolName, String sql, Object[][] params) throws YankSQLException
      Batch executes the given INSERT, UPDATE, DELETE, REPLACE or UPSERT SQL statement
      Parameters:
      poolName - The name of the connection pool to query against
      sql - The SQL statement
      params - An array of query replacement parameters. Each row in this array is one set of batch replacement values
      Returns:
      The number of rows affected or each individual execution
      Throws:
      YankSQLException
    • setupConnectionPool

      public static void setupConnectionPool(String poolName, Properties dataSourceProperties)
      Add properties for a DataSource (connection pool). Yank uses a Hikari DataSource (connection pool) under the hood, so you have to provide the minimal essential properties and the optional properties as defined here: https://github.com/brettwooldridge/HikariCP
      Parameters:
      poolName -
      dataSourceProperties -
    • setupDefaultConnectionPool

      public static void setupDefaultConnectionPool(Properties dataSourceProperties)
      Add properties for a DataSource (connection pool). Yank uses a Hikari DataSource (connection pool) under the hood, so you have to provide the minimal essential properties and the optional properties as defined here: https://github.com/brettwooldridge/HikariCP
      Parameters:
      dataSourceProperties -
    • addSQLStatements

      public static void addSQLStatements(Properties sqlProperties)
      Add SQL statements in a properties file. Adding more will merge Properties.
      Parameters:
      sqlProperties -
    • releaseConnectionPool

      public static void releaseConnectionPool(String poolName)
      Closes the given connection pool
    • releaseDefaultConnectionPool

      public static void releaseDefaultConnectionPool()
      Closes the default connection pool
    • releaseAllConnectionPools

      public static void releaseAllConnectionPools()
      Closes all connection pools
    • getDefaultConnectionPool

      public static com.zaxxer.hikari.HikariDataSource getDefaultConnectionPool()
      Exposes access to the default connection pool.
      Returns:
      a configured (pooled) HikariDataSource.
    • getConnectionPool

      public static com.zaxxer.hikari.HikariDataSource getConnectionPool(String poolName)
      Exposes access to the configured connection pool
      Returns:
      a configured (pooled) HikariDataSource.
    • isThrowWrappedExceptions

      public static boolean isThrowWrappedExceptions()
    • setThrowWrappedExceptions

      public static void setThrowWrappedExceptions(boolean throwWrappedExceptions)
      Set true if you want methods in "Yank" to throw unchecked `YankSQLException`s, which wrap checked `SQLException`s.
      Parameters:
      throwWrappedExceptions -