Whether you're writing an application or applet, you would typically call JDBC APIs to:
After coding your program, compile it as you would any other Java program. You don't need to perform any special precompile or bind steps.
Like other Java applets, you distribute your JDBC applet over the World Wide Web (WWW). Typically you would imbed the applet in a hypertext markup language (HTML) page. For example, to call the sample applet DB2Applt.java, (provided in sqllib/samples/java) you might use the tag:
<applet code="DB2Applt.class" width=325 height=275 archive="db2java.zip">
To run your applet, you need only a Java-enabled Web browser on the client machine. When you load your HTML page, the applet tag down loads the Java applet to your machine which then downloads the Java class files, including the COM.ibm.db2.jdbc.net class which is DB2's JDBC driver. When your applet calls the JDBC API to connect to DB2, the JDBC driver establishes separate communications with the DB2 database through the JDBC applet server residing on the Web server.
For your applets to run, you need to ensure that the correct files are installed in the proper places, as follows:
db2jstrt portno
where portno is an unused TCP/IP port number that applets can use.
Distribute your JDBC application as you would any other Java application. As the application uses DB2's CAE to communicate with the DB2 server, you have no special security concerns; authority verification is performed by the CAE.
To run your application on a client machine, you must also have installed on that machine:
Start your application from the GUI or command line, like any other application.
A sample application, DB2Appl.java, is provided in the sqllib/samples/java directory. If you have created the SAMPLE database, you can also run the sample by adding samples/java/samples.zip to your CLASSPATH environment variable, changing to the sqllib/samples/java directory, and entering the following command:
java DB2Appl
See SQL Reference for information on the SAMPLE database.
DB2 Universal Database supports the JDK Version 1.1 JDBC specification. You may have to modify applications and applets that are written to the JDBC Version 1.0 to work properly with DB2 Version 5.
There are also special considerations for graphical and large objects (LOBs).
The JDBC specification does not explicitly mention large objects (LOBs) or graphic types.
Treat LOBs as the corresponding LONGVAR type. Because LOB types are declared in SQL with a maximum length, ensure that you do not return arrays or strings longer than the declared limit. This consideration applies to SQL string types as well.
For GRAPHIC and DBCLOB types, treat them as the corresponding CHAR types. The following JDBC APIs behave as described below:
Notes: |