The Connection Dialog |
The connection dialog is a plugable component that can be used inside your code for quickly connecting to a data source. As such it is our starting point for data source interaction. The dialog is made up of two main components as shown below. |
|
![]() |
This is an overview of the two main sections of the Connection Dailog. Starting at the bottom with number (1), we have the driver section. This shows all the drivers available in the system so that connections can be made. These drivers are configured in a config file, along with the interface for the functions and parameters of the driver. That means that we just need to configure the xml file and put the driver JAR file in the directory configured in the file. Once the configuration is complete, the GUI interacts with the driver as configured and "know" which function and parameters to call when processing a connection. The only action required by the user here is to fill in the information in the fields provided. Once that is done, the Make New Database Connection button is pressed and the connection is either made and appears in the list (2) on top of the screen, or an error appears in the log area below. See below for more details on setting the connection parameters.(described below) The top section shows a list of all connections with their respective statements. By clicking on the icons we can create statements for SELECT, CREATE, DELETE, UPDATE and INSERT (described below) |
Note: With the db-JAPI there are two ways to make a connection; the one way is by including this dialog in the application (which accommodates user interaction with all other dialogs for statements and data preview) and the other is to call the connection function of the Connection Manager. Here is the link for the and here is the code for |
Selecting a driver and editing its values
In order to make a connection we need to select a driver and then verify the connection settings. There are two types of drivers (DRIVER and DATASOURCE) supported by JDBC. The driver type uses the connection string to pass all the parameters, with the exception of the credentials, to the driver for connecting to a data source. The datasource type uses a functional interface, which is vendor specific, to set all the parameters required for a connection. Both of these types are supported in this dialog. The information input or edited by the user is transported to the driver by the two means specified in the previous sentence. Without further a do, lets look at the specifics with the figure below: |
|
![]() |
Lets look at the numbered items on the left. Number (1) shows the JDBC ODBC drivers, which are only visible on Windows Operation Systems. These driver items are read from your Windows ODBC settings and are not configurable via the "driver.loader.xml" file. To add an item here one would have to go to "Data Sources ODBC" (under Control Panel, Administrative Tools) and add drivers, which are attached to data sources. Number (2) is pre-configured in the "driver.loader.xml" file to be visible on MS systems. This driver is a chameleon, as it is able to connect directly to a data source file that is supported by ODBC. There is one action required by the user to enable all supported ODBC types. The default supported OS systems are Windows 7, Windows XP, Windows Vista and Windows 2003 Server. The file type supported are Access, Excel, dBase(dbf), Paradox(db) and Text (txt). If other types are required, then the file "odbc.driver.xml" needs to be edited. The file name field provides a load dialog for selecting a file. Number (3) shows the MS SQL datasource driver. The items like server name, database name etc are all taken from the driver configuration and as such when values are input in the respective fields the functions that respond to these parameters are called and the values are passed to the driver. The credentials are encrypted with the dbJAPI local RSA cipher which is generated for every new installation. Number (4) shows a driver type configuration, which passes all the information to the driver through the connection URL. The default configuration has the format of the connection URL and this needs to be adhered to when specifying parameters within the string. The connection properties can contain a semi-colon ';' delimiter string of properties like encoding for instance. To use these drivers we need to fill-in or select the values from the fields below a driver and then hit the "make new database connection". |
![]() |
The charset (language) processing of the database is important as it specifies how the
driver will decode the byte stored into strings. Each driver has a pre-configured value, which is normally correct and should not have to be changed. The database name and credentials are normally the values that will require setting when a connection is to be made, although they can be set in the configuration file for one-click accessing by the user. The user name and password are guest passwords and are set in clear text in the configuration file. The credentials passed to the driver, after input by the user are encrypted together into one string with the default 1024 bit RSA cipher. |
Working with Connections and Statements
![]() |
Once a connection has been set, as above, and connected, then it appears in the list of
connections and statements in this top area of the connection dialog. The picture on the left shows that we have one connection (1) and three statements (3) that belong to that connection. The three statements show happen to be the three types that can be selected from the icons next to the connection name (2). The first SQL symbol is for creating of a new SELECT statement, the "+" symbol is for opening a CREATE statement dialog and the last SQL symbol is for the the INSERT/UPDATE/DELETE statement dialog. Each of these statements copies all the tables and columns from the connection and then presents them for user interaction on their respective window. Number (4) shows the tooltip of the current mouse position over the icons. This gives a clear indication as to the action that can be performed. Number (5) shows the tabs that are created from the statement actions performed on (2). These can be selected and the names can be changed by double clicking on the tab name. This will automatically change the name in the list under the connection. |
![]() |