Enum Class JKDatabase

java.lang.Object
java.lang.Enum<JKDatabase>
com.jk.data.datasource.JKDatabase
All Implemented Interfaces:
Serializable, Comparable<JKDatabase>, Constable

public enum JKDatabase extends Enum<JKDatabase>
This enum representing various database types along with their configuration.
Version:
1.0
Author:
Dr. Jalal H. Kiswani
  • Nested Class Summary

    Nested classes/interfaces inherited from class java.lang.Enum

    Enum.EnumDesc<E extends Enum<E>>
  • Enum Constant Summary

    Enum Constants
    Enum Constant
    Description
    Represents the DB2 database configuration.
    Represents the Derby database configuration.
    Represents the EnterpriseDB database configuration.
    Represents the H2 database configuration.
    Represents the HANA database configuration.
    Represents the HSql database configuration.
    Represents the MariaDB database configuration.
    Represents the MySql database configuration.
    Represents the Oracle database configuration.
    Represents the PostgreSql database configuration.
    Represents the SQL Server database configuration.
    Represents the SyBase database configuration.
  • Method Summary

    Modifier and Type
    Method
    Description
    abstract org.hibernate.dialect.Dialect
    This method get the corresponding Dialect instance for this database.
    This method is yet to be implemented (TBI).
    org.hibernate.dialect.Database
    This method gets the corresponding database type as a Database enum.
    static JKDatabase
    This method gets the database associated with the provided URL.
    This method is yet to be implemented (TBI).
    This method gets the query made for testing purposes.
    getTypeName(int typeCode, int maxLength, int precision, int scale)
    This method is yet to be implemented (TBI).
    static void
    main(String[] args)
    This main method demonstrate the usage of certain methods.
    readResult(ResultSet rs, JKDataType type, String fieldName)
    This method read a result from a ResultSet for this database.
    void
    setParameter(PreparedStatement ps, int index, JKDataType type, Object value)
    This method set a parameter in a PreparedStatement for this database.
    toJavaType(int sqlDataTypeNumber)
    This method convert an SQL data type number to a Java data type.
    int
    This method convert a Java data type to an SQL code for this database.
    toSqlTypeTextFromJavaType(Class<?> clas, int length, int preceision, int scale)
    This method convert a Java type to its equivalent SQL type as a text representation.
    toType(int sqlDataType)
    This method convert an SQL data type number to a JKDataType.
    abstract String
    This method gets the URL prefix for this database.
    static JKDatabase
    Returns the enum constant of this class with the specified name.
    static JKDatabase[]
    Returns an array containing the constants of this enum class, in the order they are declared.

    Methods inherited from class java.lang.Object

    getClass, notify, notifyAll, wait, wait, wait
  • Enum Constant Details

    • DB2

      public static final JKDatabase DB2
      Represents the DB2 database configuration.
    • DERBY

      public static final JKDatabase DERBY
      Represents the Derby database configuration.
    • ENTERPRISEDB

      public static final JKDatabase ENTERPRISEDB
      Represents the EnterpriseDB database configuration.
    • H2

      public static final JKDatabase H2
      Represents the H2 database configuration.
    • HANA

      public static final JKDatabase HANA
      Represents the HANA database configuration.
    • HSQL

      public static final JKDatabase HSQL
      Represents the HSql database configuration.
    • MARIADB

      public static final JKDatabase MARIADB
      Represents the MariaDB database configuration.
    • MYSQL

      public static final JKDatabase MYSQL
      Represents the MySql database configuration.
    • ORACLE

      public static final JKDatabase ORACLE
      Represents the Oracle database configuration.
    • POSTGRESQL

      public static final JKDatabase POSTGRESQL
      Represents the PostgreSql database configuration.
    • SQLSERVER

      public static final JKDatabase SQLSERVER
      Represents the SQL Server database configuration.
    • SYBASE

      public static final JKDatabase SYBASE
      Represents the SyBase database configuration.
  • Method Details

    • values

      public static JKDatabase[] values()
      Returns an array containing the constants of this enum class, in the order they are declared.
      Returns:
      an array containing the constants of this enum class, in the order they are declared
    • valueOf

      public static JKDatabase valueOf(String name)
      Returns the enum constant of this class with the specified name. The string must match exactly an identifier used to declare an enum constant in this class. (Extraneous whitespace characters are not permitted.)
      Parameters:
      name - the name of the enum constant to be returned.
      Returns:
      the enum constant with the specified name
      Throws:
      IllegalArgumentException - if this enum class has no constant with the specified name
      NullPointerException - if the argument is null
    • dialect

      public abstract org.hibernate.dialect.Dialect dialect()
      This method get the corresponding Dialect instance for this database.
      Returns:
      the dialect instance.
    • urlPrefix

      public abstract String urlPrefix()
      This method gets the URL prefix for this database.
      Returns:
      the URL prefix for this database.
    • getDatabaseByUrl

      public static JKDatabase getDatabaseByUrl(String url)
      This method gets the database associated with the provided URL.
      Parameters:
      url - Specifies the database URL.
      Returns:
      the database associated with the provided URL.
    • getDatabase

      public org.hibernate.dialect.Database getDatabase()
      This method gets the corresponding database type as a Database enum.
      Returns:
      the corresponding Database enum for this database.
    • toSqlCodeFromJavaType

      public int toSqlCodeFromJavaType(Class<?> clas)
      This method convert a Java data type to an SQL code for this database.
      Parameters:
      clas - Specifies the Java data type class.
      Returns:
      the SQL code as an integer.
    • toSqlTypeTextFromJavaType

      public String toSqlTypeTextFromJavaType(Class<?> clas, int length, int preceision, int scale)
      This method convert a Java type to its equivalent SQL type as a text representation.
      Parameters:
      clas - Specifies the Java class representing the type.
      length - Specifies the length of the SQL type.
      preceision - Specifies the precision of the SQL type.
      scale - Specifies the scale of the SQL type.
      Returns:
      the equivalent SQL type as a text representation.
    • toJavaType

      public Class<?> toJavaType(int sqlDataTypeNumber)
      This method convert an SQL data type number to a Java data type.
      Parameters:
      sqlDataTypeNumber - Specifies the SQL data type number.
      Returns:
      the corresponding Java data type class.
    • toType

      public JKDataType toType(int sqlDataType)
      This method convert an SQL data type number to a JKDataType.
      Parameters:
      sqlDataType - Specifies the SQL data type number.
      Returns:
      the corresponding JKDataType.
    • setParameter

      public void setParameter(PreparedStatement ps, int index, JKDataType type, Object value) throws SQLException
      This method set a parameter in a PreparedStatement for this database.
      Parameters:
      ps - Specifies the PreparedStatement to set the parameter in.
      index - Specifies the parameter index.
      type - Specifies the JKDataType of the parameter.
      value - Specifies the value of the parameter.
      Throws:
      SQLException - if a database access error occurs.
    • readResult

      public Object readResult(ResultSet rs, JKDataType type, String fieldName) throws SQLException
      This method read a result from a ResultSet for this database.
      Parameters:
      rs - Specifies the ResultSet to read the result from.
      type - Specifies the JKDataType of the result.
      fieldName - Specifies the field name of the result.
      Returns:
      the result value.
      Throws:
      SQLException - if a database access error occurs.
    • getTypeName

      public String getTypeName(int typeCode, int maxLength, int precision, int scale)
      This method is yet to be implemented (TBI).
      Parameters:
      typeCode - Specifies the method parameter which is yet to be implemented (TBI).
      maxLength - Specifies the method parameter which is yet to be implemented (TBI).
      precision - Specifies the method parameter which is yet to be implemented (TBI).
      scale - Specifies the method parameter which is yet to be implemented (TBI).
      Returns:
      null.
    • getPhyiscalNamingStrategy

      public String getPhyiscalNamingStrategy()
      This method is yet to be implemented (TBI).
      Returns:
      null.
    • driver

      public String driver()
      This method is yet to be implemented (TBI).
      Returns:
      null.
    • getTestQuery

      public String getTestQuery()
      This method gets the query made for testing purposes.
      Returns:
      the testing query.
    • main

      public static void main(String[] args)
      This main method demonstrate the usage of certain methods.
      Parameters:
      args - the command-line arguments.
      See Also: