The Oracle Lite Blog

The Rekounas Blog about Oracle's Mobile Enterprise Application Platform

The Oracle Lite Blog header image 2

Deploying an application using the APIs

February 15th, 2008 · 2 Comments

Here is an example of how you deploy an application. I will follow it up with examples of how to add publication items to the application and adding users to the application as well.

The following command should be all on one line:
java -classpath .:$ORACLE_HOME/mobile/classes/consolidator.jar:
$ORACLE_HOME/mobile/server/bin/devmgr.jar:
$ORACLE_HOME/mobile/server/bin/webtogo.jar:
$ORACLE_HOME/jdbc/lib/ojdbc14.jar Deploy MOBILEADMIN MOBILEPWD localhost 1521 XE


import java.sql.Connection;
import java.sql.Driver;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.SQLException;

import oracle.lite.sync.Consolidator;
import oracle.lite.sync.ConsolidatorException;
import oracle.lite.sync.ConsolidatorManager;

public class Deploy {
    private static Connection con = null;

    public static void main(String[] arg) throws ConsolidatorException,
                                                 SQLException {
        if (arg.length == 5) {
            ConsolidatorManager cm = new ConsolidatorManager();
            String PUBLICATION = "PUBLICATION";

            // arguments are:
            // 0 - Mobile Schema Repository
            // 1 - Mobile Schema Repository Password
            // 2 - URL
            // 3 - Port
            // 4 - SID
            String MOBILE_SCHEMA = arg[0];
            String MOBILE_PASSWORD = arg[1];
            String JDBC_URL =
                "jdbc:oracle:thin:@" + arg[2] + ":" + arg[3] + ":" + arg[4];

            System.out.println("JDBC URL = " + JDBC_URL);
            try {
                DriverManager.registerDriver((Driver)(Class.forName("oracle.jdbc.OracleDriver").newInstance()));
                try {
                    con = DriverManager.getConnection(JDBC_URL, MOBILE_SCHEMA, MOBILE_PASSWORD);
                } catch (SQLException sqle) {
                    sqle.printStackTrace();
                }
            } catch (Exception e) {
                e.printStackTrace();
                return;
            }

            cm.openConnection(con);

            // Alter the session if you are dealing with a multilingual application
            PreparedStatement stmt = null;
            stmt = con.prepareStatement("alter session SET NLS_LENGTH_SEMANTICS='BYTE'");
            stmt.execute();

            try {
                cm.dropPublication(PUBLICATION);
            } catch (ConsolidatorException ce) {
                System.out.println(ce.getMessage());
            }

            cm.createPublication(PUBLICATION, Consolidator.DFLT_CREATOR_ID,
                                 PUBLICATION.toLowerCase() + ".%s", null);

        } else {
            System.out.println("Invalid parameters!");
            System.out.println("java -classpath :. Deploy mobileadmin mobilepass url port sid");
        }
    }
}
Share

Tags: Java · Oracle Lite

2 responses so far ↓

  • 1 Mr.Wolf wrote on Apr 27, 2010 at 7:25 am

    My best regard to my preferred Oracle Lite guru!
    Maybe i’m wrong, but you are deploying a publication instead of an application? Did you ever try to deploy an application from scratch using API?


  • 2 rekounas wrote on Apr 27, 2010 at 9:52 am

    Mr. Wolf, you are correct. I am deploying a publication instead of an application. I sometimes use those terms interchangeably. I haven’t done it from scratch yet, but I am in the middle of building something that should be able to do it.


Leave a Comment

*