| |
JDBC Configuration
Parameters |
| |
|
| |
|
| |
|
 |
zeroCode supports
databases in two different ways: (1) You can create tables and the
rest of schema (2) You can access an existing database. |
 |
|
| |
In
the first mode, zeroCode supports Oracle, SQLServer and DB2. In these
cases, the zeroCode Design Environment (zDE) recognizes the database
that you are creating the site against and creates the tables as
needed (if you choose to do so at the time site creation).
|
|
|
|
In
the second mode, it also supports PostgreSQL and PointBase, apart
from Oracle, SQLServer and DB2. In this case, a designer can
generate a site using Oracle or SQLServer and then retarget it
against any of the other databases, by reconfiguring the JDBC
connection (an entry in the site’s config file). The zeroCode-built
site then automatically generates the appropriate SQL at run-time,
based on the configuration.
|
|
|
|
Essentially,
this mechanism gives a designer the ability to make the choice of
database at any point later than when the site was generated. Say, you
build a site using the default Oracle database on the zeroCode site.
You then find that the customer has PostgreSQL. All that you need to
do is change the config and everything works OK. You can deploy the
same site on a DB2 database, instead, by the same mechanism. This is
particularly useful when customers “upsize” from, say, PostgreSQL
to DB2. There needs to be no change in the site. This kind of thing is
absolutely impossible in a hand-crafted application.
|
|
|
|
What’s a Database connection?
|
|
To
be able to feed data into or fetch data from or to pass any commands
to and from a database, a connection needs to be established between
the client application and the database host server. JDBC
handles the actual connection, sending queries and data to and from
the database. A
driver manager class is used to open a connection to a database via a
JDBC driver which must be registered with the driver
manager. To connect with
individual databases, JDBC requires drivers for each database. To begin connecting
to a data source, you first need to instantiate an object of your JDBC
driver. This essentially requires only one line of code, a command to
the DriverManager, telling the Java Virtual Machine to load the
bytecode of your driver into memory, where its methods will be
available to your program. The Driver manager
chooses from a given list of available drivers to suit the explicit
type of database connection. Driver manager also maps URLs to the drivers.
|
|
|
| |
How does it work? |
| |
To actually
manipulate your database, you need to get an object of the
Connection class from your driver. At the very least, your driver
will need a URL for the database and parameters for access control,
which usually involves standard password authentication for a
database account. |
|
|
|
As long as you stick
with the more popular database platforms (Oracle, Informix,
Microsoft, MySQL, etc.), there is almost certainly a JDBC driver
written to let your programs connect and manipulate data. You can
download a specific JDBC driver from the manufacturer of your
database management system (DBMS) or from a third party (in the case
of less popular open source products). The JDBC driver for your
database will come with specific instructions to make the class
files of the driver available to the Java Virtual Machine, which
your program is going to run. JDBC drivers use Java's built-in
DriverManager to open and access a database from within your Java
program. Information on the configuration parameters like the JDBC
driver class, the JDBC URL etc. also come along with the download. |
|
|
|
You can make your
zeroCode generated site compatible to different kinds of database.
Download the JDBC drivers and store it in the class path for
zeroCode. zeroCode then recognizes the JDBC driver and makes your
site respond to the corresponding database. |
|
|
|
In zeroCode, the
JDBC driver class is stored in the stdlib directory. The JDBC driver
class is included in the form of a jar file. This driver class
enables the connection to be established between the client and the
database server. This in turn will allow you to easily pass commands
through it to the database. |
|
|
|
|
|
|
| |
|