Package com.jk.data.datasource
Enum Class JKDatabase
- All Implemented Interfaces:
Serializable
,Comparable<JKDatabase>
,Constable
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 ConstantsEnum ConstantDescriptionRepresents 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 TypeMethodDescriptionabstract org.hibernate.dialect.Dialect
dialect()
This method get the corresponding Dialect instance for this database.driver()
This method is yet to be implemented (TBI).org.hibernate.dialect.Database
This method gets the corresponding database type as aDatabase
enum.static JKDatabase
getDatabaseByUrl
(String url) 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
This main method demonstrate the usage of certain methods.readResult
(ResultSet rs, JKDataType type, String fieldName) This method read a result from aResultSet
for this database.void
setParameter
(PreparedStatement ps, int index, JKDataType type, Object value) This method set a parameter in a PreparedStatement for this database.Class<?>
toJavaType
(int sqlDataTypeNumber) This method convert an SQL data type number to a Java data type.int
toSqlCodeFromJavaType
(Class<?> clas) 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 aJKDataType
.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[]
values()
Returns an array containing the constants of this enum class, in the order they are declared.
-
Enum Constant Details
-
DB2
Represents the DB2 database configuration. -
DERBY
Represents the Derby database configuration. -
ENTERPRISEDB
Represents the EnterpriseDB database configuration. -
H2
Represents the H2 database configuration. -
HANA
Represents the HANA database configuration. -
HSQL
Represents the HSql database configuration. -
MARIADB
Represents the MariaDB database configuration. -
MYSQL
Represents the MySql database configuration. -
ORACLE
Represents the Oracle database configuration. -
POSTGRESQL
Represents the PostgreSql database configuration. -
SQLSERVER
Represents the SQL Server database configuration. -
SYBASE
Represents the SyBase database configuration.
-
-
Method Details
-
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
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 nameNullPointerException
- 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
This method gets the URL prefix for this database.- Returns:
- the URL prefix for this database.
-
getDatabaseByUrl
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 aDatabase
enum.- Returns:
- the corresponding
Database
enum for this database.
-
toSqlCodeFromJavaType
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
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
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
This method convert an SQL data type number to aJKDataType
.- 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 theJKDataType
of the parameter.value
- Specifies the value of the parameter.- Throws:
SQLException
- if a database access error occurs.
-
readResult
This method read a result from aResultSet
for this database.- Parameters:
rs
- Specifies theResultSet
to read the result from.type
- Specifies theJKDataType
of the result.fieldName
- Specifies the field name of the result.- Returns:
- the result value.
- Throws:
SQLException
- if a database access error occurs.
-
getTypeName
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
This method is yet to be implemented (TBI).- Returns:
- null.
-
driver
This method is yet to be implemented (TBI).- Returns:
- null.
-
getTestQuery
This method gets the query made for testing purposes.- Returns:
- the testing query.
-
main
This main method demonstrate the usage of certain methods.- Parameters:
args
- the command-line arguments.- See Also:
-