Package dev.king.universal.shared.api
Interface JdbcProvider
- All Known Implementing Classes:
MysqlProvider
,SqlProvider
public interface JdbcProvider
The interface has provide basic methods
-
Method Summary
Modifier and Type Method Description <T> int[]
batch(@NonNull java.lang.String query, SafetyBiConsumer<T,ComputedBatchQuery> batchFunction, java.util.Collection<T> collection)
Execute massive updatevoid
closeConnection()
Close the all connections of jdbcboolean
hasConnection()
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 queryboolean
openConnection()
Connect to mysql serverJdbcProvider
preOpen()
Deprecated.<K> K
query(@NonNull java.lang.String query, @NonNull SafetyFunction<java.sql.ResultSet,K> consumer, java.lang.Object... objects)
Uses just in select queryvoid
update(@NonNull java.lang.String query, java.lang.Object... objects)
Uses just in create, delete, insert and update queries
-
Method Details
-
openConnection
boolean openConnection()Connect to mysql server- Returns:
- if has a valid connection
-
preOpen
Deprecated.Used to pre configure instance settings- Returns:
- instance of current
JdbcProvider
-
closeConnection
void closeConnection()Close the all connections of jdbc -
hasConnection
boolean hasConnection()Verify if the connections is valid- Returns:
- if an any valid connection
-
update
void update(@NonNull @NonNull java.lang.String query, java.lang.Object... objects)Uses just in create, delete, insert and update queries- Parameters:
query
- the query of mysqlobjects
- the objects that will be putted in the prepared statement
-
map
<K> java.util.List<K> map(@NonNull @NonNull java.lang.String query, @NonNull @NonNull SafetyFunction<java.sql.ResultSet,K> function, java.lang.Object... objects)Uses just in select query- Type Parameters:
K
- the generic type, used to return your prefer value- Parameters:
query
- the query of mysqlfunction
- if has a valid entry, functional interfaceSafetyFunction
will be called and returns a resultobjects
- the objects that will be put in the prepared statement- Returns:
- returns a optional value, applied in function parameter
-
query
<K> K query(@NonNull @NonNull java.lang.String query, @NonNull @NonNull SafetyFunction<java.sql.ResultSet,K> consumer, java.lang.Object... objects)Uses just in select query- Type Parameters:
K
- the generic type, used to return your prefer value- Parameters:
query
- the query of mysqlconsumer
- if has a valid entry, functional interfaceSafetyFunction
will be called and returns a resultobjects
- the objects that will be put in the prepared statement- Returns:
- returns a optional value, applied in function parameter
-
batch
<T> int[] batch(@NonNull @NonNull java.lang.String query, SafetyBiConsumer<T,ComputedBatchQuery> batchFunction, java.util.Collection<T> collection)Execute massive update- Type Parameters:
T
- type of objects- Parameters:
query
- the query of mysqlbatchFunction
- to compute values from collectioncollection
- entry of computable objects- Returns:
- result of batch
-