Connecting to a database
Before a query can be executed, the JdbcSource applet must connect to an external database. To do this, the following information must be supplied:
- Database URL - specifies the correct database in URL form
- User - specifies the user ID (if needed) to login to the database
- Password - specifies the password (if needed) to login to the database
- Connection trigger - specifies that a connection has been made
All of this information can be relayed via the applet PARAM tags. The following sample HTML code shows the PARAM tags needed to connect automatically to a database that requires a user ID and a password. In this case, the JDBC driver is also automatically loaded.
<APPLET NAME="dataBase1" CODEBASE="..\..\.." CODE="lotus.jdbc.JdbcSource" WIDTH=1 HEIGHT=1>
<PARAM NAME="driver" VALUE="JDBC driver classname">
<PARAM NAME="autoload" VALUE="true">
<PARAM NAME="database" VALUE="databaseURL">
<PARAM NAME="user" VALUE="databaseID">
<PARAM NAME="password" VALUE="databasePassword">
<PARAM NAME="autoconnect" VALUE="true">
</APPLET>
The following JdbcSource PARAM tags specify the options for connecting to the database:
The tag option is specified by the NAME attribute and the option value is specified by the VALUE attribute of the tag.
Within the APPLET tag, the various attributes do the following:
- NAME assigns a reference name to the applet so that you can refer to it in your code.
- CODEBASE specifies the base URL of the applet. That is, the directory or folder that contains the applet's code. If this attribute is not specified, then the document's URL is used.
- CODE gives the name of the file that contains the applet's compiled Applet subclass. This file is relative to the base URL of the applet. It cannot be absolute.
- WIDTH and HEIGHT define the size of the applet's display region in the HTML document. This is measured in pixels. In the case of this applet, minimal dimensions are given to the applet so that it remains invisible. You can achieve the same result by setting the allowUI PARAM tag to "False."