Package com.jk.data.util
Class JKDataAccessUtil
java.lang.Object
com.jk.data.util.JKDataAccessUtil
This class provides utility methods for working with data access operations.
It includes methods for formatting SQL statements, handling binary data from ResultSets, and more.
- Version:
- 1.0
- Author:
- Dr. Jalal H. Kiswani
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic List
fetchArray
(Array array) This method fetches elements of an Array as a list.static List
This method fetches the elements of aStruct
object as a list.static Object
fetchValue
(Object a) This method fetches a value from an object.static String
formatStatement
(String statement) This method formats a SQL statement by adding indentation for readability.static String
formatStatementWithParam
(String statement, Object... params) This method formats a SQL statement with its parameters.static byte[]
getBinaryStream
(ResultSet rs, String name) This method retrieves binary data from a ResultSet using the specified column name.static byte[]
getBlobColumn
(ResultSet rs, String columnName) This method retrieves binary data from a ResultSet as a Blob using the specified column name.static Properties
This method retrieves JDBC driver properties from a properties file.static void
This method pings a database to check its availability.
-
Constructor Details
-
JKDataAccessUtil
public JKDataAccessUtil()
-
-
Method Details
-
formatStatement
This method formats a SQL statement by adding indentation for readability.- Parameters:
statement
- Specifies the SQL statement to format.- Returns:
- the formatted SQL statement.
-
formatStatementWithParam
This method formats a SQL statement with its parameters.- Parameters:
statement
- Specifies the SQL statement to format.params
- Specifies the parameters associated with the statement.- Returns:
- the formatted SQL statement with parameters.
-
getBinaryStream
This method retrieves binary data from a ResultSet using the specified column name.- Parameters:
rs
- Specifies the ResultSet containing the binary data.name
- Specifies the name of the column.- Returns:
- the binary data as a byte array.
- Throws:
SQLException
- if a SQL error occurs while retrieving the data.
-
getBlobColumn
This method retrieves binary data from a ResultSet as a Blob using the specified column name.- Parameters:
rs
- Specifies the ResultSet containing the binary data as a Blob.columnName
- Specifies the name of the column.- Returns:
- the binary data as a byte array.
- Throws:
SQLException
- if a SQL error occurs while retrieving the data.
-
getJdbcDrivers
This method retrieves JDBC driver properties from a properties file.- Returns:
- the JDBC driver properties as a Properties object.
-
ping
This method pings a database to check its availability.- Parameters:
driver
- Specifies the JDBC driver class name.url
- Specifies the database URL.user
- Specifies the database user.password
- Specifies the database password.
-
fetchStruct
This method fetches the elements of aStruct
object as a list.- Parameters:
s
- Specifies theStruct
object to fetch elements from.- Returns:
- a list of elements from the
Struct
.
-
fetchValue
This method fetches a value from an object.- Parameters:
a
- Specifies the object to fetch a value from.- Returns:
- the fetched value.
- See Also:
-
fetchArray
This method fetches elements of an Array as a list.- Parameters:
array
- Specifies the Array object to fetch elements from.- Returns:
- the list of elements from the Array.
-