Databases And Types


There are many vendors offering databases. Each dbms usually has some proprietary data types. 

The JDBC driver can enumerate a dbms' data types, and propose which Java data types should be used for a given dbms type.

Some tables in databases may be of one type (VARCHAR for example), but are known to hold a more specific kind of data (NUMERIC for example).

The wizard generates Java code to interact with the database. In order for the wizard to be able to decide which Java types to use for each database entity type, the wizard uses a type map.

The JDatabase wizard is equipped to deal with these situations. This section describes how the JDatabase wizard can be used to finely control which Java data types to use for every object in the database, or for individual columns of a table.

The code generated will contain data conversion routines where necessary.

Database Tab

The database tab is the first tab seen when flipping to the database view.

In most circumstances, it is not necessary to change information on this tab. One exception we have come across is when using Microsoft Access databases (via the JDBC-ODBC bridge). We have disabled catalogs, because the database does not typically use catalog names in SQL queries.

Database Type Map

The database type map tab allows the user to override the default data mappings used when a new class is created. The wizard uses the type map to determine which conversion, if any needs to be generated in the source code.

Type Map Controls:

Database Entity Type Maps

As stated in the introduction, some database objects may be specified as of one type, when the data they contain is of another type. The JDatabase wizard can be made to convert between types for a given database object by using  the class view tab.

 We use the Property Editor to tell the JDatabase wizard what the "Property Type" is, what ResultSet.get...() and set to call. The database JDBC type is salso specified here.

The code generated will attempt to convert data types between the "get set op" and the "property type", should they be diferent.

The sql access (select, insert, update) can be selected here.

The advanced tab allows server side expressions to be entered for insert and update operations. The column access should include insert/update for the settings below to take effect.

Please note that no question mark (?) character may be entered here.

The expressions can be used when the database does not allow default column values to be set.

JDBC Types Supported

Version 1.0 of the JDatabase wizard supports the following JDBC types.


Generated Names

When creating a database class within the wizard, data class properties are created. For example in a PERSON table, FIRST_NAME, LAST_NAME, table columns have a corresponding property created for them.

When a class is created, the wizard can apply java styling to the column names. This is usually a good idea. Database objects names do not always make good java class property names. However, sometimes this may not be the preferred option.

When checked, the checkbox causes all new classes to use java styling. This means that data class properties fit in with the java naming conventions. For example a FIRST_NAME column becomes a FirstName data class property. If the checkbox is not checked, any new generated data classes will use FIRST_NAME as the java class property name.

This option only affects new classes created in the wizard. Any existing classes in the wizard retain their original property names.

Copyright © 2002 J3 Limited, all rights reserved.