Package dev.king.universal.wrapper.sql
Class SqlProvider
java.lang.Object
dev.king.universal.wrapper.sql.SqlProvider
- All Implemented Interfaces:
- JdbcProvider
public final class SqlProvider extends java.lang.Object implements JdbcProvider
- 
Constructor SummaryConstructors Constructor Description SqlProvider()
- 
Method SummaryModifier and Type Method Description <T> int[]batch(@NonNull java.lang.String query, SafetyBiConsumer<T,ComputedBatchQuery> batchFunction, java.util.Collection<T> collection)Execute massive updatevoidcloseConnection()Close the all connections of jdbcstatic JdbcProviderfrom(@NonNull java.io.File file)Creates provider to sqlbooleanhasConnection()Verify if the connections is valid<K> java.util.List<K>map(@NonNull java.lang.String query, @NonNull SafetyFunction<java.sql.ResultSet,K> function, java.lang.Object... objects)Uses just in select querybooleanopenConnection()Connect to mysql serverJdbcProviderpreOpen()Used to pre configure instance settings<K> Kquery(@NonNull java.lang.String query, @NonNull SafetyFunction<java.sql.ResultSet,K> consumer, java.lang.Object... objects)Uses just in select queryvoidupdate(@NonNull java.lang.String query, java.lang.Object... objects)Uses just in create, delete, insert and update queries
- 
Constructor Details- 
SqlProviderpublic SqlProvider()
 
- 
- 
Method Details- 
fromCreates provider to sql- Parameters:
- file- path of file
- Returns:
- instance of sql provider
 
- 
closeConnectionpublic void closeConnection()Description copied from interface:JdbcProviderClose the all connections of jdbc- Specified by:
- closeConnectionin interface- JdbcProvider
 
- 
hasConnectionpublic boolean hasConnection()Description copied from interface:JdbcProviderVerify if the connections is valid- Specified by:
- hasConnectionin interface- JdbcProvider
- Returns:
- if an any valid connection
 
- 
openConnectionpublic boolean openConnection()Description copied from interface:JdbcProviderConnect to mysql server- Specified by:
- openConnectionin interface- JdbcProvider
- Returns:
- if has a valid connection
 
- 
preOpenDescription copied from interface:JdbcProviderUsed to pre configure instance settings- Specified by:
- preOpenin interface- JdbcProvider
- Returns:
- instance of current JdbcProvider
 
- 
querypublic <K> K query(@NonNull @NonNull java.lang.String query, @NonNull @NonNull SafetyFunction<java.sql.ResultSet,K> consumer, java.lang.Object... objects)Description copied from interface:JdbcProviderUses just in select query- Specified by:
- queryin interface- JdbcProvider
- Type Parameters:
- K- the generic type, used to return your prefer value
- Parameters:
- query- the query of mysql
- consumer- if has a valid entry, functional interface- SafetyFunctionwill be called and returns a result
- objects- the objects that will be put in the prepared statement
- Returns:
- returns a optional value, applied in function parameter
 
- 
updatepublic void update(@NonNull @NonNull java.lang.String query, java.lang.Object... objects)Description copied from interface:JdbcProviderUses just in create, delete, insert and update queries- Specified by:
- updatein interface- JdbcProvider
- Parameters:
- query- the query of mysql
- objects- the objects that will be putted in the prepared statement
 
- 
mappublic <K> java.util.List<K> map(@NonNull @NonNull java.lang.String query, @NonNull @NonNull SafetyFunction<java.sql.ResultSet,K> function, java.lang.Object... objects)Description copied from interface:JdbcProviderUses just in select query- Specified by:
- mapin interface- JdbcProvider
- Type Parameters:
- K- the generic type, used to return your prefer value
- Parameters:
- query- the query of mysql
- function- if has a valid entry, functional interface- SafetyFunctionwill be called and returns a result
- objects- the objects that will be put in the prepared statement
- Returns:
- returns a optional value, applied in function parameter
 
- 
batchpublic <T> int[] batch(@NonNull @NonNull java.lang.String query, SafetyBiConsumer<T,ComputedBatchQuery> batchFunction, java.util.Collection<T> collection)Description copied from interface:JdbcProviderExecute massive update- Specified by:
- batchin interface- JdbcProvider
- Type Parameters:
- T- type of objects
- Parameters:
- query- the query of mysql
- batchFunction- to compute values from collection
- collection- entry of computable objects
- Returns:
- result of batch
 
 
-