Package com.jk.core.util
Class JKJdbcUtil
java.lang.Object
com.jk.core.util.JKJdbcUtil
This class is a utility class used for JDBC (Java Database Connectivity)
operations and handling.
- Version:
- 1.0
- Author:
- Dr. Jalal H. Kiswani
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic byte[]
getBinaryStream
(ResultSet rs, String name) This method retrieves a binary stream from the specified column in the given result set and converts it into a byte array.static byte[]
getBlobColumn
(ResultSet rs, String columnName) This method retrieves a BLOB (Binary Large Object) column from the result set and converts it into a byte array.static Properties
This method reads JDBC driver information.static void
This is the main method of the class.static void
This method tests database connectivity using the provided JDBC driver, URL, user name, and password.
-
Constructor Details
-
JKJdbcUtil
public JKJdbcUtil()
-
-
Method Details
-
getBinaryStream
This method retrieves a binary stream from the specified column in the given result set and converts it into a byte array.- Parameters:
rs
- Specifies the result set containing the data.name
- Specifies the name of the column containing the binary data.- Returns:
- the byte array containing the binary data, or null if the data is absent.
- Throws:
SQLException
- if there's an issue retrieving the binary stream.
-
getBlobColumn
This method retrieves a BLOB (Binary Large Object) column from the result set and converts it into a byte array.- Parameters:
rs
- Specifies the result set containing the data.columnName
- Specifies the name of the BLOB column.- Returns:
- the byte array containing the BLOB data, or null if the data is absent.
- Throws:
SQLException
- if there's an issue retrieving the BLOB column.
-
getJdbcDrivers
This method reads JDBC driver information.- Returns:
- the Properties object containing JDBC driver information.
-
main
This is the main method of the class.When executed, it prints JDBC driver properties.
- Parameters:
args
- the command-line arguments.
-
ping
This method tests database connectivity using the provided JDBC driver, URL, user name, and password.This method attempts to establish a connection and then closes it.
- Parameters:
driver
- Specifies the fully qualified name of the JDBC driver class.url
- Specifies the URL for the database connection.user
- Specifies the user name for authentication.password
- Specifies the password for authentication.
-