Package com.iizix.jdbc
Class JDBCHelper
java.lang.Object
com.iizix.jdbc.JDBCHelper
Derby instance for iiziGo and iiziServer.
- Author:
- Christopher Mindus
Constructor Summary
Method Summary
Modifier and TypeMethodDescriptionstatic int
Disposes of created instance and stops the Derby network server if started.static IDBConnectionPool
Constructs the Derby database connection pool from a directory that can contain a "dbconf.properties" file.static IDBConnectionPool
from
(String name, PropCnr cnr, Properties driverProps) Creates a database connection pool from values stored in a property container.static IDBConnectionPool
Constructs the database connection pool from a directory that should contain a "dbconf.properties" file.static URL[]
getClassLoaderURLs
(File dir, String classPath) Parses the classPath into URL's with the specified directory as the relative directory.static File
initialize
(IFileURLResolver resolver) Initializes the file resolver and looks up the[resources/]jdbc-drivers
directory.static String
setUsePrivateDirectory
(boolean doCopy) Sets the JDBC drivers directory to be the user's private directory "~/.iizi/jdbc-drivers".
Constructor Details
JDBCHelper
public JDBCHelper()
Method Details
setUsePrivateDirectory
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
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:
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
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. Ifdir
isnull
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:
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
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:
IOException
- For I/O errors.SQLException
- For errors in creating the database pool.
from
public static IDBConnectionPool from(String name, DerbyImpl derbyImpl) throws IOException, 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:
IOException
- For I/O errors.SQLException
- For errors in creating the database pool.
from
public static IDBConnectionPool from(String name, PropCnr cnr, Properties driverProps) throws SQLException, 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:
SQLException
- For errors in creating the database poolIOException
- 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.