Skip Headers
Oracle® Database Lite Developer's Guide for Java
10g (10.0.0)
Part No. B13811-01
  Go To Table Of Contents
Contents
Go To Index
Index

Previous
Previous
Next
Next
 

2 Application Development

This chapter describes how to develop and test Java applications. Topics include:

2.1 Oracle Database Lite Java Support

This section describes Java interfaces and tools supported by Oracle Database Lite. Topics include:

2.1.1 Java Datatypes

Oracle Database Lite performs type conversions between Java and Oracle datatypes as indicated by the following table. Table 2-1 lists the Java datatypes and the corresponding SQL datatypes that result from the type conversion.

Table 2-1 Datatype Conversions

Java Datatype SQL Datatype
byte[], byte[][], Byte[] BINARY, RAW, VARBINARY, BLOB
boolean, Boolean BIT
String, String[] CHAR, VARCHAR, VARCHAR2, CLOB
short, short[], short[][], Short, Short[] SMALLINT
int,int[], int[][], Integer, Integer[] INT
float, float[], float[][], Float, Float[] REAL
double, double[], double[][], Double, Double[] DOUBLE, NUMBER (without precision)
BigDecimal, BigDecimal[] NUMBER(n)
java.sql.Date, java.sql.Date[] DATE
java.sql.Time, java.sql.Time[] TIME
java.sql.Timestamp, java.sql.Timestamp[] TIMESTAMP
java.sql.Connection Default JDBC connection to database

2.1.2 Java Tools

Oracle Database Lite provides tools to manage Java development. Table 2-2 lists these Java tools and their descriptions.

Table 2-2 Java Tools

Tool Description
loadjava Loads Java classes into Oracle Database Lite.
dropjava Removes Java classes from Oracle Database Lite.

2.1.2.1 loadjava

The loadjava utility automates the task of loading Java class and resource files into Oracle Database Lite. Using loadjava, you can load class and resource files individually, or in ZIP or JAR archives.

After you load the class, create a call specification for the methods in the class that you want to make accessible to SQL statements. To create a call specification for a stored procedure that returns a value, use the SQL CREATE FUNCTION statement. If the stored procedure does not return a value, use the CREATE PROCEDURE statement.

For unloading classes, Oracle Database Lite provides dropjava, which works in a similar manner as the loadjava utility.

2.1.3 Oracle Database Lite Java Development Environment

The following tools facilitate Java development for Oracle Database Lite.

  • Oracle Developer 2.1 supports Java stored procedures written in Oracle Database Lite by users.

  • Oracle JDeveloper also supports Java stored procedures in Oracle Database Lite, and includes features designed specifically to help develop and deploy Java stored procedures.

2.1.3.1 Environment Setup

This section describes how to set up your development environment to create Oracle Database Lite applications. To develop Java applications, you must have the Sun Microsystems Java Development Kit (JDK), version 1.3.1 (or higher).

To enable Oracle Database Lite to work with the JDK, set your PATH and CLASSPATH environment variables, after you install Oracle Database Lite. Depending on the version of JDK that you are using, the PATH and CLASSPATH settings may vary. The following sections summarize these variations.

If your environment includes a CLASSPATH user variable before you install Oracle Database Lite, and the user variable does not include the CLASSPATH system variable (is not specified as CLASSPATH=...;%CLASSPATH%), you must modify the CLASSPATH user variable to include the OLITE40.JAR file in the &fmv75;\mobile\classes directory.


Note:

All command prompt windows must be closed and reopened to reflect changes made to your CLASSPATH.

Setting Variables for JDK 1.3.1

If you are using JDK 1.3.1, the directory with the JDK 1.3.1 Java compiler (javac.exe) should be in the PATH variable before any other directories that contain other Java compilers.

Add the directory that contains the Classic Java Virtual Machine (JVM) shared library, jvm.dll, to the PATH. jvm.dll should be in your JDK_Home\jre\bin\classic directory.

For example,

set PATH=C:\JDK_Home\bin;c:\JDK_Home\jre\bin\classic

set CLASSPATH=c:\JDK_Home\jrc\lib\rt.jar;c:\&fmv76;\Mobile\classes\olite40.jar

As an alternative to using the Classic JVM, you can use the HotSpot JVM. HotSpot is a JDK add on module provided by Sun Microsystems. HotSpot is available from the Sun Microsystems Web site.

After installing HotSpot, set your PATH as given below.

set PATH=c:\jdk1.3.1\bin;c:\jdk1.3.1\jre\bin\hotspot;%PATH%

In the example above, your installation of the JDK and HotSpot is on Drive C. You should verify the location of your installation before amending your PATH statement. To test whether your system is set up correctly, run the Java examples in the &fmv77;\Mobile\Sdk\Samples\JDBC directory.

2.2 Java Development Tools

To write and debug Java programs, you can use any Java development tool. However, you must ensure that you set the CLASSPATH and PATH correctly.

2.3 Developing and Testing the Application

Before synchronizing your database with the Mobile Server, you must create a seed database by publishing a dummy application and synchronize it to the client machine. This creates a sample database with the correct schema and table definitions. If you are not synchronizing your database, you should first create the database with sample tables and data.

2.4 Packaging the Application

At this stage, you must package and publish the application.

To package Java applications using the Packaging Wizard, refer the Oracle Database Lite Tools and Utilities Guide.

To publish the application, refer to Section 4.6, "Uploading Applications to the Mobile Server Repository" in the Oracle Database Lite Administration and Deployment Guide.

2.5 Testing

The publishing phase can be termed as the testing phase for your applications. To test your Java applications, publish the application using the Packaging Wizard. For more information, refer Section 4.6, "Uploading Applications to the Mobile Server Repository" in the Oracle Database Lite Administration and Deployment Guide.

2.6 MSync/OCAPIs/mSyncCom

For more information, refer the Java mSync API Specification.