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 update
    void closeConnection()
    Close the all connections of jdbc
    boolean 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 query
    boolean openConnection()
    Connect to mysql server
    JdbcProvider 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 query
    void 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 JdbcProvider 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 mysql
      objects - 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 mysql
      function - if has a valid entry, functional interface SafetyFunction will 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
    • 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 mysql
      consumer - if has a valid entry, functional interface SafetyFunction will 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
    • 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 mysql
      batchFunction - to compute values from collection
      collection - entry of computable objects
      Returns:
      result of batch