Class SQL

java.lang.Object
xyz.geik.farmer.database.SQL
Direct Known Subclasses:
MySQL, SQLite

public abstract class SQL extends Object
SQL Queries and abstracted methods exist in this class
Since:
b000
Author:
Amowny
  • Constructor Details

    • SQL

      public SQL()
      Constructor of class
  • Method Details

    • createTable

      public abstract void createTable()
      Creates table on db
    • updateAllFarmers

      public void updateAllFarmers()
      Updates all farmers which saves all data of farmers on cache
    • updateAllFarmersAsync

      public void updateAllFarmersAsync()
      Does same thing with #updateAllFarmers async
    • loadAllFarmers

      public void loadAllFarmers()
      Loads all farmer data from sql to cache
    • createFarmer

      public void createFarmer(@NotNull @NotNull Farmer farmer)
      Creates farmer on sql
      Parameters:
      farmer - temp farmer
    • removeFarmer

      public void removeFarmer(@NotNull @NotNull Farmer farmer)
      Removes farmer from sql
      Parameters:
      farmer - object of farmer
    • saveFarmer

      public void saveFarmer(@NotNull @NotNull Farmer farmer)
      Saves farmer sync
      Parameters:
      farmer - farmer object
    • addUser

      public void addUser(UUID uuid, String name, FarmerPerm perm, @NotNull @NotNull Farmer farmer)
      Adds user to farmer in sql
      Parameters:
      uuid - uuid of player
      name - name of player
      perm - perm of player
      farmer - farmer of region
    • addUser

      public void addUser(@NotNull @NotNull UUID uuid, String name, FarmerPerm perm, int farmerId)
      Adds user to farmer in sql only
      Parameters:
      uuid - of player
      name - of player
      perm - of player perm FarmerPerm#perm
      farmerId - id of farmer
    • removeUser

      public boolean removeUser(@NotNull @NotNull User user, Farmer farmer)
      Removes user from farmer in sql
      Parameters:
      user - user object
      farmer - of region
      Returns:
      status of task
    • updateRole

      public void updateRole(UUID uuid, int roleId, int farmerId)
      Updates role of player
      Parameters:
      uuid - uuid of player
      roleId - roleId of player (FarmerPerm#getRole)
      farmerId - id of farmer
    • getDatabaseType

      public abstract DatabaseType getDatabaseType()
      Database type of sql
      Returns:
      DatabaseType object
    • closeConnections

      protected void closeConnections(PreparedStatement preparedStatement, Connection connection, ResultSet resultSet)
      Closes connection of sql
      Parameters:
      preparedStatement - statement
      connection - connection
      resultSet - resultSet
    • fixDatabase

      public void fixDatabase()
      Fix database method

      Fixes users and owners if there is any corruption occurred in older versions or blackouts.