Package com.jk.data.datasource
Interface JKDataSource
- All Superinterfaces:
 Synchronizable
- All Known Implementing Classes:
 JKAbstractDataSource,JKHibernateDataSource,JKPlainDataSource
This interface defines methods for managing database connections and
 entities.
- Version:
 - 1.0
 - Author:
 - Dr. Jalal H. Kiswani
 
- 
Method Summary
Modifier and TypeMethodDescriptionvoidclose()This method closes the data source.voidclose(jakarta.persistence.EntityManager manager, boolean commit) This method close an entity manager with an option to commit the transaction.voidclose(Connection con) This method closes a database connection.voidclose(Connection connection, boolean commit) This method close a database connection with an option to commit the transaction.This method creates a database connection.jakarta.persistence.EntityManagerThis method creates an entity manager.default StringgetBaseScriptPath(JKDatabase databaseType) This method get the base script path for a specific database type.This method gets a database connection.default StringThis method get the name of the connected database.default StringThis method gets the database password.This method gets the type of database.default StringThis method gets the database URL from the properties.default StringThis method gets the database user name.intThis method get the maximum number of allowed connections.This method gets the properties associated with the data source.This method gets a query-specific database connection.default intThis method gets the rows limit.voidinit()This method initiates the data source.booleanisEntityAvailable(Class<?> clas) This method checks whether the entity is available or not.voidsetProperty(String property, String value) This method property for the data source. 
- 
Method Details
- 
createConnection
Connection createConnection()This method creates a database connection.- Returns:
 - a database connection.
 
 - 
getConnection
Connection getConnection()This method gets a database connection.- Returns:
 - a database connection.
 
 - 
getQueryConnection
Connection getQueryConnection()This method gets a query-specific database connection.- Returns:
 - a query-specific database connection.
 
 - 
close
This method closes a database connection.- Parameters:
 con- Specifies the database connection to close.
 - 
close
This method close a database connection with an option to commit the transaction.- Parameters:
 connection- Specifies the database connection to close.commit- Indicates whether to commit the transaction (true), or not (false).
 - 
createEntityManager
jakarta.persistence.EntityManager createEntityManager()This method creates an entity manager.- Returns:
 - an entity manager.
 
 - 
isEntityAvailable
This method checks whether the entity is available or not.- Parameters:
 clas- Specifies the class of the entity to check.- Returns:
 - true, if the entity is available, false otherwise.
 
 - 
close
void close(jakarta.persistence.EntityManager manager, boolean commit) This method close an entity manager with an option to commit the transaction.- Parameters:
 manager- Specifies the entity manager to close.commit- Indicates whether to commit the transaction (true) or not (false).
 - 
getProperties
Properties getProperties()This method gets the properties associated with the data source.- Returns:
 - the properties.
 
 - 
setProperty
This method property for the data source.- Parameters:
 property- Specifies the property for the data source.value- Specifies the value of the property.
 - 
getDatabaseType
JKDatabase getDatabaseType()This method gets the type of database.- Returns:
 - the database type.
 
 - 
getDatabaseName
This method get the name of the connected database.- Returns:
 - the database name.
 
 - 
getBaseScriptPath
This method get the base script path for a specific database type.- Parameters:
 databaseType- Specifies the type of database.- Returns:
 - the base script path.
 
 - 
getDatabaseUrl
This method gets the database URL from the properties.- Returns:
 - the database URL.
 
 - 
getRowsLimit
default int getRowsLimit()This method gets the rows limit.- Returns:
 - the rows limit.
 
 - 
getDatabaseUsername
This method gets the database user name.- Returns:
 - the database user name.
 
 - 
getDatabasepassword
This method gets the database password.- Returns:
 - the database password.
 
 - 
getMaxAllowedConnections
int getMaxAllowedConnections()This method get the maximum number of allowed connections.- Returns:
 - the maximum number of allowed connections.
 
 - 
close
void close()This method closes the data source. - 
init
void init()This method initiates the data source. 
 -