Class JDBCHelper


  • public class JDBCHelper
    extends java.lang.Object
    Derby instance for iiziGo and iiziServer.
    Author:
    Christopher Mindus
    • Constructor Summary

      Constructors 
      ConstructorDescription
      JDBCHelper() 
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and TypeMethodDescription
      static intdisposeAll()
      Disposes of created instance and stops the Derby network server if started.
      static IDBConnectionPoolfrom​(java.lang.String name, DerbyImpl derbyImpl)
      Constructs the Derby database connection pool from a directory that can contain a "dbconf.properties" file.
      static IDBConnectionPoolfrom​(java.lang.String name, PropCnr cnr, java.util.Properties driverProps)
      Creates a database connection pool from values stored in a property container.
      static IDBConnectionPoolfrom​(java.lang.String name, java.io.File dir)
      Constructs the database connection pool from a directory that should contain a "dbconf.properties" file.
      static java.net.URL[]getClassLoaderURLs​(java.io.File dir, java.lang.String classPath)
      Parses the classPath into URL's with the specified directory as the relative directory.
      static java.io.Fileinitialize​(IFileURLResolver resolver)
      Initializes the file resolver and looks up the [resources/]jdbc-drivers directory.
      static java.lang.StringsetUsePrivateDirectory​(boolean doCopy)
      Sets the JDBC drivers directory to be the user's private directory "~/.iizi/jdbc-drivers".
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • JDBCHelper

        public JDBCHelper()
    • Method Detail

      • setUsePrivateDirectory

        public static java.lang.String setUsePrivateDirectory​(boolean doCopy)
        Sets the JDBC drivers directory to be the user's private directory "~/.iizi/jdbc-drivers".
        Parameters:
        doCopy - Flag to perform copy of the normal JDBC drivers directory to the user's private directory "~/.iizi/jdbc-drivers".
        Returns:
        Error message for failure, null for success.
      • initialize

        public static java.io.File initialize​(IFileURLResolver resolver)
                                       throws java.io.IOException
        Initializes the file resolver and looks up the [resources/]jdbc-drivers directory.
        Parameters:
        resolver - The URL to File resolver.
        Returns:
        The canonical directory for the jdbc-drivers.
        Throws:
        java.io.IOException - If the the [resources/]jdbc-drivers directory is not found, or if the user's private directory for JDBC drivers "~/.iizi/jdbc-drivers" is not found or copy/update or drivers and files failed.
      • getClassLoaderURLs

        public static java.net.URL[] getClassLoaderURLs​(java.io.File dir,
                                                        java.lang.String classPath)
                                                 throws java.io.IOException
        Parses the classPath into URL's with the specified directory as the relative directory.
        Parameters:
        dir - The directory that is used for relative paths in the classpath for directories This directory is normally the one containing the 'dbconf*.properties' file to process the 'classpath' entry. If dir is null the classpath must either contain absolute paths or in case of no classpath, an empty URL array is returned.
        classPath - The classpath with a comma as separator (not the system separator ";" for Windows or ":" for other systems). To specify a comma, enter it twice. The path must consist of either directories or (Jar) files.
        Returns:
        The URL's is never an empty array. If classPath is null or empty string, the URL is set to the dir URL.
        Throws:
        java.io.IOException - If the classPath references non-existent or erroneous paths, or the path part is a file that is does not have the '.jar' or '.zip' file extension.
      • from

        public static IDBConnectionPool from​(java.lang.String name,
                                             java.io.File dir)
                                      throws java.io.IOException,
                                             java.sql.SQLException
        Constructs the database connection pool from a directory that should contain a "dbconf.properties" file.
        Parameters:
        name - The name of the database connection pool.
        dir - The directory where the "dbconf.properties" should be present.
        Throws:
        java.io.IOException - For I/O errors.
        java.sql.SQLException - For errors in creating the database pool.
      • from

        public static IDBConnectionPool from​(java.lang.String name,
                                             DerbyImpl derbyImpl)
                                      throws java.io.IOException,
                                             java.sql.SQLException
        Constructs the Derby database connection pool from a directory that can contain a "dbconf.properties" file.
        Parameters:
        name - The name of the database connection pool.
        derbyImpl - The Derby implementation.
        Returns:
        The database connection pool.
        Throws:
        java.io.IOException - For I/O errors.
        java.sql.SQLException - For errors in creating the database pool.
      • from

        public static IDBConnectionPool from​(java.lang.String name,
                                             PropCnr cnr,
                                             java.util.Properties driverProps)
                                      throws java.sql.SQLException,
                                             java.io.IOException
        Creates a database connection pool from values stored in a property container.
        Parameters:
        name - The name of the database connection pool.
        cnr - The property container.
        driverProps - The driver properties, null for none.
        Returns:
        The database connection pool.
        Throws:
        java.sql.SQLException - For errors in creating the database pool
        java.io.IOException - For I/O errors.
      • disposeAll

        public static int disposeAll()
        Disposes of created instance and stops the Derby network server if started.
        Returns:
        count of disposed instances, zero for none.