public class Yank extends Object
| Modifier and Type | Method and Description |
|---|---|
static void |
addSQLStatements(Properties sqlProperties)
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 |
getConnectionPool(String poolName)
Exposes access to the configured connection pool
|
static com.zaxxer.hikari.HikariDataSource |
getDataSource()
Deprecated.
|
static com.zaxxer.hikari.HikariDataSource |
getDefaultConnectionPool()
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 |
isThrowWrappedExceptions() |
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[]> |
queryObjectArrays(String sql,
Object[] params)
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[]> |
queryObjectArraysSQLKey(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(...) 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 |
releaseAllConnectionPools()
Closes all connection pools
|
static void |
releaseConnectionPool(String poolName)
Closes the given connection pool
|
static void |
releaseDataSource()
Deprecated.
use
releaseDefaultConnectionPool() instead.
Closes the default connection pool |
static void |
releaseDefaultConnectionPool()
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 |
setupDataSource(Properties dataSourceProperties)
Deprecated.
use
#setupDefaultConnectionPool() instead.
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 |
static void |
setupDefaultConnectionPool(Properties dataSourceProperties)
Add properties for a DataSource (connection pool).
|
public static Long insertSQLKey(String sqlKey, Object[] params) throws SQLStatementNotFoundException, YankSQLException
sqlKey - The SQL Key found in a properties file corresponding to the desired SQL statement valueparams - The replacement parametersSQLStatementNotFoundException - if an SQL statement could not be found for the given sqlKey StringYankSQLExceptionpublic static Long insertSQLKey(String poolName, String sqlKey, Object[] params) throws SQLStatementNotFoundException, YankSQLException
poolName - The name of the connection pool to query againstsqlKey - The SQL Key found in a properties file corresponding to the desired SQL statement valueparams - The replacement parametersSQLStatementNotFoundException - if an SQL statement could not be found for the given sqlKey StringYankSQLExceptionpublic static Long insert(String sql, Object[] params) throws YankSQLException
sql - The query to executeparams - The replacement parametersYankSQLExceptionpublic static Long insert(String poolName, String sql, Object[] params) throws YankSQLException
poolName - The name of the connection pool to query againstsql - The query to executeparams - The replacement parametersYankSQLExceptionpublic static int executeSQLKey(String sqlKey, Object[] params) throws SQLStatementNotFoundException, YankSQLException
sqlKey - The SQL Key found in a properties file corresponding to the desired SQL statement valueparams - The replacement parametersSQLStatementNotFoundException - if an SQL statement could not be found for the given sqlKey StringYankSQLExceptionpublic static int executeSQLKey(String poolName, String sqlKey, Object[] params) throws SQLStatementNotFoundException, YankSQLException
poolName - The name of the connection pool to query againstsqlKey - The SQL Key found in a properties file corresponding to the desired SQL statement valueparams - The replacement parametersSQLStatementNotFoundException - if an SQL statement could not be found for the given sqlKey StringYankSQLExceptionpublic static int execute(String sql, Object[] params) throws YankSQLException
sql - The query to executeparams - The replacement parametersYankSQLExceptionpublic static int execute(String poolName, String sql, Object[] params) throws YankSQLException
poolName - The name of the connection pool to query againstsql - The query to executeparams - The replacement parametersYankSQLExceptionpublic static <T> T queryScalarSQLKey(String sqlKey, Class<T> scalarType, Object[] params) throws SQLStatementNotFoundException, YankSQLException
sqlKey - The SQL Key found in a properties file corresponding to the desired SQL statement valuescalarType - The Class of the desired return scalar matching the tableparams - The replacement parametersSQLStatementNotFoundException - if an SQL statement could not be found for the given sqlKey StringYankSQLExceptionpublic static <T> T queryScalarSQLKey(String poolName, String sqlKey, Class<T> scalarType, Object[] params) throws SQLStatementNotFoundException, YankSQLException
poolName - The name of the connection pool to query againstsqlKey - The SQL Key found in a properties file corresponding to the desired SQL statement valuescalarType - The Class of the desired return scalar matching the tableparams - The replacement parametersSQLStatementNotFoundException - if an SQL statement could not be found for the given sqlKey StringYankSQLExceptionpublic static <T> T queryScalar(String sql, Class<T> scalarType, Object[] params) throws SQLStatementNotFoundException, YankSQLException
scalarType - The Class of the desired return scalar matching the tableparams - The replacement parametersSQLStatementNotFoundException - if an SQL statement could not be found for the given sqlKey StringYankSQLExceptionpublic static <T> T queryScalar(String poolName, String sql, Class<T> scalarType, Object[] params) throws SQLStatementNotFoundException, YankSQLException
poolName - The name of the connection pool to query againstscalarType - The Class of the desired return scalar matching the tableparams - The replacement parametersSQLStatementNotFoundException - if an SQL statement could not be found for the given sqlKey StringYankSQLExceptionpublic static <T> T queryBeanSQLKey(String sqlKey, Class<T> beanType, Object[] params) throws SQLStatementNotFoundException, YankSQLException
sqlKey - The SQL Key found in a properties file corresponding to the desired SQL statement valueparams - The replacement parametersbeanType - The Class of the desired return Object matching the tableSQLStatementNotFoundException - if an SQL statement could not be found for the given sqlKey StringYankSQLExceptionpublic static <T> T queryBeanSQLKey(String poolName, String sqlKey, Class<T> beanType, Object[] params) throws SQLStatementNotFoundException, YankSQLException
poolName - The name of the connection pool to query againstsqlKey - The SQL Key found in a properties file corresponding to the desired SQL statement valueparams - The replacement parametersbeanType - The Class of the desired return Object matching the tableSQLStatementNotFoundException - if an SQL statement could not be found for the given sqlKey StringYankSQLExceptionpublic static <T> T queryBean(String sql, Class<T> beanType, Object[] params) throws YankSQLException
sql - The SQL statementparams - The replacement parametersbeanType - The Class of the desired return Object matching the tableYankSQLExceptionpublic static <T> T queryBean(String poolName, String sql, Class<T> beanType, Object[] params) throws YankSQLException
poolName - The name of the connection pool to query againstsql - The SQL statementparams - The replacement parametersbeanType - The Class of the desired return Object matching the tableYankSQLExceptionpublic static <T> List<T> queryBeanListSQLKey(String sqlKey, Class<T> beanType, Object[] params) throws SQLStatementNotFoundException, YankSQLException
sqlKey - The SQL Key found in a properties file corresponding to the desired SQL statement valuebeanType - The Class of the desired return Objects matching the tableparams - The replacement parametersSQLStatementNotFoundException - if an SQL statement could not be found for the given sqlKey StringYankSQLExceptionpublic static <T> List<T> queryBeanListSQLKey(String poolName, String sqlKey, Class<T> beanType, Object[] params) throws SQLStatementNotFoundException, YankSQLException
poolName - The name of the connection pool to query againstsqlKey - The SQL Key found in a properties file corresponding to the desired SQL statement valuebeanType - The Class of the desired return Objects matching the tableparams - The replacement parametersSQLStatementNotFoundException - if an SQL statement could not be found for the given sqlKey StringYankSQLExceptionpublic static <T> List<T> queryBeanList(String sql, Class<T> beanType, Object[] params) throws YankSQLException
sql - The SQL statementbeanType - The Class of the desired return Objects matching the tableparams - The replacement parametersYankSQLExceptionpublic static <T> List<T> queryBeanList(String poolName, String sql, Class<T> beanType, Object[] params) throws YankSQLException
poolName - The name of the connection pool to query againstsql - The SQL statementbeanType - The Class of the desired return Objects matching the tableparams - The replacement parametersYankSQLExceptionpublic static <T> List<T> queryColumnSQLKey(String sqlKey, String columnName, Class<T> columnType, Object[] params) throws SQLStatementNotFoundException, YankSQLException
sqlKey - The SQL Key found in a properties file corresponding to the desired SQL statement valueparams - The replacement parameterscolumnType - The Class of the desired return Objects matching the tableSQLStatementNotFoundException - if an SQL statement could not be found for the given sqlKey StringYankSQLExceptionpublic static <T> List<T> queryColumnSQLKey(String poolName, String sqlKey, String columnName, Class<T> columnType, Object[] params) throws SQLStatementNotFoundException, YankSQLException
poolName - The name of the connection pool to query againstsqlKey - The SQL Key found in a properties file corresponding to the desired SQL statement valueparams - The replacement parameterscolumnType - The Class of the desired return Objects matching the tableSQLStatementNotFoundException - if an SQL statement could not be found for the given sqlKey StringYankSQLExceptionpublic static <T> List<T> queryColumn(String sql, String columnName, Class<T> columnType, Object[] params) throws YankSQLException
T - sql - The SQL statementparams - The replacement parameterscolumnType - The Class of the desired return Objects matching the tableYankSQLExceptionpublic static <T> List<T> queryColumn(String poolName, String sql, String columnName, Class<T> columnType, Object[] params) throws YankSQLException
poolName - The name of the connection pool to query againstsql - The SQL statementparams - The replacement parameterscolumnType - The Class of the desired return Objects matching the tableYankSQLExceptionpublic static List<Object[]> queryObjectArraysSQLKey(String sqlKey, Object[] params) throws SQLStatementNotFoundException, YankSQLException
sqlKey - The SQL Key found in a properties file corresponding to the desired SQL statement valueparams - The replacement parametersSQLStatementNotFoundException - if an SQL statement could not be found for the given sqlKey StringYankSQLExceptionpublic static List<Object[]> queryObjectArraysSQLKey(String poolName, String sqlKey, Object[] params) throws SQLStatementNotFoundException, YankSQLException
poolName - The name of the connection pool to query againstsqlKey - The SQL Key found in a properties file corresponding to the desired SQL statement valueparams - The replacement parametersSQLStatementNotFoundException - if an SQL statement could not be found for the given sqlKey StringYankSQLExceptionpublic static List<Object[]> queryObjectArrays(String sql, Object[] params) throws YankSQLException
sql - The SQL statementparams - The replacement parametersYankSQLExceptionpublic static List<Object[]> queryObjectArrays(String poolName, String sql, Object[] params) throws YankSQLException
poolName - The name of the connection pool to query againstsql - The SQL statementparams - The replacement parametersYankSQLExceptionpublic static int[] executeBatchSQLKey(String sqlKey, Object[][] params) throws SQLStatementNotFoundException, YankSQLException
sqlKey - The SQL Key found in a properties file corresponding to the desired SQL statement valueparams - An array of query replacement parameters. Each row in this array is one set of batch replacement valuesSQLStatementNotFoundException - if an SQL statement could not be found for the given sqlKey StringYankSQLExceptionpublic static int[] executeBatchSQLKey(String poolName, String sqlKey, Object[][] params) throws SQLStatementNotFoundException, YankSQLException
poolName - The name of the connection pool to query againstsqlKey - The SQL Key found in a properties file corresponding to the desired SQL statement valueparams - An array of query replacement parameters. Each row in this array is one set of batch replacement valuesSQLStatementNotFoundException - if an SQL statement could not be found for the given sqlKey StringYankSQLExceptionpublic static int[] executeBatch(String sql, Object[][] params) throws YankSQLException
sql - The SQL statementparams - An array of query replacement parameters. Each row in this array is one set of batch replacement valuesYankSQLExceptionpublic static int[] executeBatch(String poolName, String sql, Object[][] params) throws YankSQLException
poolName - The name of the connection pool to query againstsql - The SQL statementparams - An array of query replacement parameters. Each row in this array is one set of batch replacement valuesYankSQLException@Deprecated public static void setupDataSource(Properties dataSourceProperties)
#setupDefaultConnectionPool() instead.
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
dataSourceProperties - public static void setupConnectionPool(String poolName, Properties dataSourceProperties)
poolName - dataSourceProperties - public static void setupDefaultConnectionPool(Properties dataSourceProperties)
dataSourceProperties - public static void addSQLStatements(Properties sqlProperties)
sqlProperties - @Deprecated public static void releaseDataSource()
releaseDefaultConnectionPool() instead.
Closes the default connection pool
public static void releaseConnectionPool(String poolName)
public static void releaseDefaultConnectionPool()
public static void releaseAllConnectionPools()
public static com.zaxxer.hikari.HikariDataSource getDefaultConnectionPool()
public static com.zaxxer.hikari.HikariDataSource getConnectionPool(String poolName)
@Deprecated public static com.zaxxer.hikari.HikariDataSource getDataSource()
public static boolean isThrowWrappedExceptions()
public static void setThrowWrappedExceptions(boolean throwWrappedExceptions)
throwWrappedExceptions - Copyright © 2011–2017 Knowm Inc.. All rights reserved.