Interface JKDataSource

All Superinterfaces:
Synchronizable
All Known Implementing Classes:
JKAbstractDataSource, JKHibernateDataSource, JKPlainDataSource

public interface JKDataSource extends Synchronizable
This interface defines methods for managing database connections and entities.
Version:
1.0
Author:
Dr. Jalal H. Kiswani
  • 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

      void close(Connection con)
      This method closes a database connection.
      Parameters:
      con - Specifies the database connection to close.
    • close

      void close(Connection connection, boolean commit)
      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

      boolean isEntityAvailable(Class<?> clas)
      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

      void setProperty(String property, String value)
      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

      default String getDatabaseName()
      This method get the name of the connected database.
      Returns:
      the database name.
    • getBaseScriptPath

      default String getBaseScriptPath(JKDatabase databaseType)
      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

      default String 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

      default String getDatabaseUsername()
      This method gets the database user name.
      Returns:
      the database user name.
    • getDatabasepassword

      default String 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.