Klasse Database

java.lang.Object
de.murmelmeister.murmelapi.utils.Database

public final class Database extends Object
  • Konstruktordetails

    • Database

      public Database()
  • Methodendetails

    • connect

      public static void connect(String url, String user, String password)
      Connects to the database using the provided URL, username and password.
      Parameter:
      url - The JDBC URL for the database.
      user - The username for the database.
      password - The password for the database.
    • connect

      public static void connect(String driver, String hostname, String port, String database, String username, String password)
      Connects to the database using the provided driver, host, port, database, username, and password.
      Parameter:
      driver - The JDBC driver for the database.
      hostname - The hostname of the database.
      port - The port of the database.
      database - The name of the database.
      username - The username for the database.
      password - The password for the database.
    • disconnect

      public static void disconnect()
      Disconnects from the database and close the connection pool.
    • update

      public static void update(String sql) throws SQLException
      Send an update in the database.
      Parameter:
      sql - SQL command
      Löst aus:
      SQLException
    • update

      public static void update(String sql, Object... objects) throws SQLException
      Update the sql which the String.format(String, Object...).
      Parameter:
      sql - SQL command
      objects - String.format(String, Object...)
      Löst aus:
      SQLException
    • getValue

      public static <T> T getValue(T defaultValue, Class<T> type, String value, String sql) throws SQLException
      Obtain a value.
      Typparameter:
      T - Which type return
      Parameter:
      defaultValue - Set a default value
      type - Type what value have
      value - Value what you get
      sql - SQL command
      Gibt zurück:
      A type what do you will to get
      Löst aus:
      SQLException
    • getValues

      public static <T> List<T> getValues(List<T> list, Class<T> type, String value, String sql) throws SQLException
      Obtain a value list.
      Typparameter:
      T - Which type return
      Parameter:
      list - Set a default list
      type - Type what value have
      value - Value what you get
      sql - SQL command
      Gibt zurück:
      A type list what do you will to get
      Löst aus:
      SQLException
    • exists

      public static boolean exists(String sql) throws SQLException
      Exists the value in the database.
      Parameter:
      sql - SQL command
      Gibt zurück:
      True if exists the value
      Löst aus:
      SQLException
    • exists

      public static boolean exists(String sql, Object... objects) throws SQLException
      Exists the value in the database.
      Parameter:
      sql - SQL command
      objects - String.format(String, Object...)
      Gibt zurück:
      True if exists the value
      Löst aus:
      SQLException
    • getString

      public static String getString(String defaultValue, String value, String sql) throws SQLException
      Obtain the string value.
      Parameter:
      defaultValue - Set a default string
      value - Value what you get
      sql - SQL command
      Gibt zurück:
      A String what do you will to get
      Löst aus:
      SQLException
    • getString

      public static String getString(String defaultValue, String value, String sql, Object... objects) throws SQLException
      Obtain the string value.
      Parameter:
      defaultValue - Set a default string
      value - Value what you get
      sql - SQL command
      objects - String.format(String, Object...)
      Gibt zurück:
      A String what do you will to get
      Löst aus:
      SQLException
    • getInt

      public static int getInt(int defaultValue, String value, String sql) throws SQLException
      Obtain the int value.
      Parameter:
      defaultValue - Set a default int
      value - Value what you get
      sql - SQL command
      Gibt zurück:
      An int what do you will to get
      Löst aus:
      SQLException
    • getInt

      public static int getInt(int defaultValue, String value, String sql, Object... objects) throws SQLException
      Obtain the int value.
      Parameter:
      defaultValue - Set a default int
      value - Value what you get
      sql - SQL command
      objects - String.format(String, Object...)
      Gibt zurück:
      An int what do you will to get
      Löst aus:
      SQLException
    • getLong

      public static long getLong(long defaultValue, String value, String sql) throws SQLException
      Obtain the long value.
      Parameter:
      defaultValue - Set a default long
      value - Value what you get
      sql - SQL command
      Gibt zurück:
      A long what do you will to get
      Löst aus:
      SQLException
    • getLong

      public static long getLong(long defaultValue, String value, String sql, Object... objects) throws SQLException
      Obtain the long value.
      Parameter:
      defaultValue - Set a default long
      value - Value what you get
      sql - SQL command
      objects - String.format(String, Object...)
      Gibt zurück:
      A long what do you will to get
      Löst aus:
      SQLException
    • getFloat

      public static float getFloat(float defaultValue, String value, String sql) throws SQLException
      Obtain the float value.
      Parameter:
      defaultValue - Set a default float
      value - Value what you get
      sql - SQL command
      Gibt zurück:
      A float what do you will to get
      Löst aus:
      SQLException
    • getFloat

      public static float getFloat(float defaultValue, String value, String sql, Object... objects) throws SQLException
      Obtain the float value.
      Parameter:
      defaultValue - Set a default float
      value - Value what you get
      sql - SQL command
      objects - String.format(String, Object...)
      Gibt zurück:
      A float what do you will to get
      Löst aus:
      SQLException
    • getDouble

      public static double getDouble(double defaultValue, String value, String sql) throws SQLException
      Obtain the double value.
      Parameter:
      defaultValue - Set a default double
      value - Value what you get
      sql - SQL command
      Gibt zurück:
      A double what do you will to get
      Löst aus:
      SQLException
    • getDouble

      public static double getDouble(double defaultValue, String value, String sql, Object... objects) throws SQLException
      Obtain the double value.
      Parameter:
      defaultValue - Set a default double
      value - Value what you get
      sql - SQL command
      objects - String.format(String, Object...)
      Gibt zurück:
      A double what do you will to get
      Löst aus:
      SQLException
    • getUniqueId

      public static UUID getUniqueId(UUID defaultValue, String value, String sql) throws SQLException
      Obtain the id.
      Parameter:
      defaultValue - Set a default id
      value - Value what you get
      sql - SQL command
      Gibt zurück:
      A UniqueId what do you will to get
      Löst aus:
      SQLException
    • getUniqueId

      public static UUID getUniqueId(UUID defaultValue, String value, String sql, Object... objects) throws SQLException
      Obtain the id.
      Parameter:
      defaultValue - Set a default id
      value - Value what you get
      sql - SQL command
      objects - String.format(String, Object...)
      Gibt zurück:
      A UniqueId what do you will to get
      Löst aus:
      SQLException
    • getStringList

      public static List<String> getStringList(List<String> list, String value, String sql) throws SQLException
      Obtain the string list.
      Parameter:
      list - Set a default list
      value - Value what you get
      sql - SQL command
      Gibt zurück:
      A String list what do you will to get
      Löst aus:
      SQLException
    • getStringList

      public static List<String> getStringList(List<String> list, String value, String sql, Object... objects) throws SQLException
      Obtain the string list.
      Parameter:
      list - Set a default list
      value - Value what you get
      sql - SQL command
      objects - String.format(String, Object...)
      Gibt zurück:
      A String list what do you will to get
      Löst aus:
      SQLException
    • getIntList

      public static List<Integer> getIntList(List<Integer> list, String value, String sql) throws SQLException
      Obtain the int list.
      Parameter:
      list - Set a default list
      value - Value what you get
      sql - SQL command
      Gibt zurück:
      An int list what do you will to get
      Löst aus:
      SQLException
    • getIntList

      public static List<Integer> getIntList(List<Integer> list, String value, String sql, Object... objects) throws SQLException
      Obtain the int list.
      Parameter:
      list - Set a default list
      value - Value what you get
      sql - SQL command
      objects - String.format(String, Object...)
      Gibt zurück:
      An int list what do you will to get
      Löst aus:
      SQLException
    • getUniqueIdList

      public static List<UUID> getUniqueIdList(List<UUID> list, String value, String sql) throws SQLException
      Obtain the id list.
      Parameter:
      list - Set a default list
      value - Value what you get
      sql - SQL command
      Gibt zurück:
      A UUID list what do you will to get
      Löst aus:
      SQLException
    • getUniqueIdList

      public static List<UUID> getUniqueIdList(List<UUID> list, String value, String sql, Object... objects) throws SQLException
      Obtain the id list.
      Parameter:
      list - Set a default list
      value - Value what you get
      sql - SQL command
      objects - String.format(String, Object...)
      Gibt zurück:
      A UUID list what do you will to get
      Löst aus:
      SQLException
    • getDataSource

      public static com.zaxxer.hikari.HikariDataSource getDataSource()