Package com.jk.data.datasource
Class JKDataSourceFactory
java.lang.Object
com.jk.data.datasource.JKDataSourceFactory
This class is a factory for creating and managing JKDataSource instances.
- Version:
- 1.0
- Author:
- Dr. Jalal H. Kiswani
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic void
close()
This method closes allJKDataSource
instances and de-registers JDBC drivers associated with them.static void
This method de-registers all JDBC drivers that have been registered with theDriverManager
.static JKDataSource
createDataSource
(String driver, String url, String userName, String password, Class<?> dialect, String datasourceName) This method creates a newJKDataSource
instance with the provided database configuration.static JKDataSource
createDataSource
(String name, Properties prop) This method creates a new JKDataSource instance with the provided name and properties.static JKDataSource
getDataSource
(String prefix) This method retrieves aJKDataSource
instance with the specified prefix.static JKDataSource
This method gets the default data source.
-
Constructor Details
-
JKDataSourceFactory
public JKDataSourceFactory()
-
-
Method Details
-
getDefaultDataSource
This method gets the default data source.- Returns:
- the default data source.
-
getDataSource
This method retrieves aJKDataSource
instance with the specified prefix.- Parameters:
prefix
- Specifies the prefix used to identify the data source configuration.- Returns:
- a
JKDataSource
instance configured with the specified prefix.
-
createDataSource
public static JKDataSource createDataSource(String driver, String url, String userName, String password, Class<?> dialect, String datasourceName) This method creates a newJKDataSource
instance with the provided database configuration.- Parameters:
driver
- Specifies the JDBC driver class name.url
- Specifies the JDBC URL for the database connection.userName
- Specifies the database user name used for authentication.password
- Specifies the database password used for authentication.dialect
- Specifies the dialect class for the database.datasourceName
- Specifies the name of the data source.- Returns:
- the newly created
JKDataSource
instance.
-
createDataSource
This method creates a new JKDataSource instance with the provided name and properties.- Parameters:
name
- Specifies the name of the data source.prop
- Specifies the properties containing database configuration.- Returns:
- the newly created
JKDataSource
instance.
-
close
public static void close()This method closes allJKDataSource
instances and de-registers JDBC drivers associated with them. -
closeDrivers
public static void closeDrivers()This method de-registers all JDBC drivers that have been registered with theDriverManager
.
-