com.sd.odbc
Class ODBC

java.lang.Object
  |
  +--com.sd.odbc.ODBC

public class ODBC
extends java.lang.Object

This class has a few static native functions that allow the user to effectively manage ODBC DataSource names. Here is a list of the functionality they provide:

1. Obtain a list of all registered DataSource names.

2. Obtain a list of all installed ODBC drivers.

3. Register a new DataSource name.

4. Unregister a DataSource name.

To use it, please make sure that SD-ODBC.dll is placed in a directory included in your PATH variable.


Method Summary
static DataSource[] getDataSources()
          Native function that returns all registered ODBC data source names.
static ODBCDriver[] getDrivers()
          Native function that returns all installed ODBC drivers.
static DataSource registerDataSource(java.lang.String dsn, java.lang.String driver, java.lang.String attributes)
          Native function that registers a DataSource name.
static boolean unregisterDataSource(java.lang.String dsn, java.lang.String driver)
          Native function that unregisters a DataSource name.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

getDataSources

public static DataSource[] getDataSources()
Native function that returns all registered ODBC data source names.
Returns:
an array of data source names

getDrivers

public static ODBCDriver[] getDrivers()
Native function that returns all installed ODBC drivers.
Returns:
an array of ODBC drivers

registerDataSource

public static DataSource registerDataSource(java.lang.String dsn,
                                            java.lang.String driver,
                                            java.lang.String attributes)
Native function that registers a DataSource name. To avoid any thread safety problems using the ODBC API, this function is syncronized. Its execution is usually very fast, so synchronizing it should not impact the performance.
Parameters:
dsn - the name of the DSN to be registered
driver - the name of the driver to be used for registeration. For example: "Microsoft dBase Driver (*.dbf)".
attributes - a string with additional arguments. Each entry follows the syntax "key=value;". For example: "DefaultDir=c:\\data;". For more information please refer to the ODBC documentation for the specific driver used.
Returns:
a DataSource object that was just registered or null if something went wrong

unregisterDataSource

public static boolean unregisterDataSource(java.lang.String dsn,
                                           java.lang.String driver)
Native function that unregisters a DataSource name. To avoid any thread safety problems using the ODBC API, this function is syncronized. Its execution is usually very fast, so synchronizing it should not impact the performance.
Parameters:
dsn - the name of the DSN to be unregistered
driver - the name of the driver to be used for unregisteration. For example: "Microsoft dBase Driver (*.dbf)".
Returns:
true, if succesfully unregistered, otherwise - false