Using the JDBC Driver in ADF Mobile for Android

This section describes how to build and use BDB JDBC driver for Android in ADF Mobile.

  1. Setup the ADF Mobile environments:

    • ADF Business Components: 11.1.2.4.39.64.36.1

    • ADF Mobile Framework: 11.1.2.4.39.64

    • JDeveloper: 11g Release 2(11.1.2.4.0)

  2. Prepare the building environment.

    1. Download the OJEC1.1.1 headless package from

      http://www.oracle.com/technetwork/java/embedded/downloads/javame/index.html#2

      Unzip it and move btclasses.zip from OJEC1.1.1_HOME to OJEC1.1.1_HOME/lib.

    2. Download the JDBC driver package javasqlite-20150419.tar.gz from http://www.ch-werner.de/javasqlite. Then, in the directory <db>/dist,

      ./s_sql_drivers -jdbc \
      		-jdbc_package /path/to/javasqlite-20150419.tar.gz \
      		-noaddons

      This will install the package with a few necessary patches to <db>/lang/sql/jdbc.

    3. Modify BDB_HOME/lang/sql/jdbc/config.ojec11 as follows:

      • Specify OJEC_HOME with the location where OJEC1.1.1 is unzipped to

      • Specify JDBCSQLITE_HOME with BDB_HOME/build_unix/jdbc

      • Remove foundation.jar from BOOT_CLASSPATH

      • Remove the last line which is "./configure"
    4. Export the variables in config.ojec11 to the environment using an appropriate shell command for example, ". BDB_HOME/lang/sql/jdbc/config.ojec11".

  3. Build the Android JDBC driver.

    For instructions on how to build Android JDBC driver, see Building the Android JDBC Driver.

    Ensure that the JDBC driver includes SQLite/JDBC0 classes by "jar tf sqlite.jar".

  4. Apply Android JDBC in ADF Mobile.

    1. Download the ADF Mobile in JDeveloper by selecting Help -> Check for Updates. The ADF Mobile extension will be downloaded in jdev_install/jdeveloper/jdev/extensions/oracle.adf.mobile.

    2. In JDeveloper, open the HR sample application in jdev_install/jdeveloper/jdev/extensions/oracle.adf.mobile/Samples/HR.

    3. Add BDB Android JDBC to application libraries and classpath.

    4. Replace the JDBC driver in ADF Mobile framework as follows.

      $ cd jdev_install/jdeveloper/jdev/extensions/oracle.adf.mobile
      /Android
      $ unzip Oracle_ADFmf_Framework.zip
      ...
      $ cp <db>/build_unix/jdbc/sqlite.jar ./framework/Android/build/
      java_res_<release and debug>/assets/storage/jvm/lib/
      $ cp <db>/build_android/jdbc/libs/armeabi/liboracle-jdbc.so .
      /framework/Android/build/java_res_<release and debug>/assets/storage
      /jvm/lib/
      $ zip -9 -r Oracle_ADFmf_Framework.zip framework
      ...
      $ rm -fr framework
      
  5. Modify the sample application.

    1. Migrate the database file from SQLite to BDB by the following commands:

      $ cd HR_SAMPLE/.adf/META-INF
      $ mv HR.db HR.db.orig
      $ mv hr.sql hr.sql.orig
      $ vi hr.sql (Remove all lines with "COMMIT" and "REM") $ 
      BDB_HOME/build_unix/dbsql HR.db
      .read hr.sql
      .exit
      
    2. Modify LifeCycleListernImpl.start() method by replacing the try catch block of getting a connection and executing the query with copyDB().

  6. Run the sample application.

    1. Configure the ADF Mobile preferences for Android. Select Tools -> Preferences -> ADF Mobile -> Platforms -> Android. Specify the locations of Android SDK, Android platform, and the keystore in the Release mode which is used to sign on the application.

    2. Create a deployment profile. Select Application -> Deploy -> New Deployment Profile. Choose ADF Mobile for Android as profile type. In the form of deployment profile properties, choose Release Mode.

    3. Launch the Android SDK Manager and start the AVD emulator.

    4. Deploy the application by selecting Application -> deploy -> (the_just_created_deployment_profile). Before deployment, ensure that the folder HR_SAMPLE/deploy is removed.

    5. Run the application by clicking the application icon in the emulator.