Class JKJdbcUtil

java.lang.Object
com.jk.core.util.JKJdbcUtil

public class JKJdbcUtil extends Object
This class is a utility class used for JDBC (Java Database Connectivity) operations and handling.
Version:
1.0
Author:
Dr. Jalal H. Kiswani
  • Constructor Details

    • JKJdbcUtil

      public JKJdbcUtil()
  • Method Details

    • getBinaryStream

      public static byte[] getBinaryStream(ResultSet rs, String name) throws SQLException
      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

      public static byte[] getBlobColumn(ResultSet rs, String columnName) throws SQLException
      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

      public static Properties getJdbcDrivers()
      This method reads JDBC driver information.
      Returns:
      the Properties object containing JDBC driver information.
    • main

      public static void main(String[] args)
      This is the main method of the class.

      When executed, it prints JDBC driver properties.

      Parameters:
      args - the command-line arguments.
    • ping

      public static void ping(String driver, String url, String user, String password)
      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.