7 Replies Latest reply: Jul 18, 2013 3:13 AM by vasileios RSS

    using api to create new users


      Hi guys,

      I would like to know if it's possible to create OLite (version 10.3.x) users using the Java API from a client with SDK installed.

      I managed to get a small java program compiled, but when I execute it, it returns:

      java.io.FileNotFoundException: \mobile\server\bin\mobileserverid.dat (The system  cannot find the path specified)

      However, it looks like the user is deleted...


      The code looks like:




      Any idea, or should I just ignore the message?


      Thanks for any input.


        • 1. Re: using api to create new users

          HI Christian,


              I do not know the answer for 10.3 but will go off and investigate and get back to you.    Give me a day or 2 and I will post another response.




          • 2. Re: using api to create new users

            HI Christian,


               your code looks correct.  It looks like the stacktrace is being written out to the screen when it should not be.  You are using the correct APIs.   Is the user not getting created?  With what you have provided us so far, we will dig into this in more detail.   For these APIs, it should not be looking for  \mobile\server\bin\mobileserverid.dat.    This is a file on the server side.     If we find a bug in the code, we will fix it and put it out in the next consolidated patch release for 10.3.    I do not control the schedule for those but you can check MOS.



            • 3. Re: using api to create new users

              a long time ago i did that for oracle lite 10gr3 so here it goes:


              view registered users


              DriverManager.registerDriver ((Driver)Class.forName ("oracle.jdbc.driver.OracleDriver").newInstance ());


              String url="jdbc:oracle:thin:@servername:port:oracleinstance" ;




              c=DriverManager.getConnection( url,"mobileadmin", "mobileadminpass );




              s.executeQuery("Select NAME from MOBILEADMIN.USERS");


              ResultSet rs =s.getResultSet();


              list1.removeAll();//list1 is just a list component













              remove user

              String url="jdbc:oracle:thin:@servername:port:oracleinstance" ;





              update pass


                                  oracle.mobile.admin.ResourceManager.setPassword(user, jTextField9.getText().trim());



              add user to group




              i had created a user group in oracle lite and gave access to an application. therefore

              each time i added a user in the olite group , the user also gained access to the application and thus could download

              the cab files(in my case the client was wince but that doesnt make any diffrence)


              add user


                          oracle.mobile.admin.ResourceManager.createUser(newUsername, newUserPass, newUserFullaname, priviledge);//priviledge i used "U" for user



              for data subsetting it was kinda tricky:)


              and then i did a

              oracle.lite.sync.Consolidator.setSubscriptionParameter(publicationname,user , variablename, variablevalue);

              data subsetting is when you want a user to download a specific subset of the data and not all the table. eg. a salesman must download his own sales and not all sales.



              see users devices

              private Command  Installcmd = null;

              private Command  ForceInstall = null;

              private Command  UpdateDMC = null;


              String url=mobileadmin+"/"+mobileadminpass+"@jdbc:oracle:thin:@"+servername+":"+port+":" +oracleinstance ;


              rm = ResourceManager.getInstance();

              User usr = rm.getUser(user);


              for (Enumeration e = usr.getDevices(); e.hasMoreElements();) {

                                  // Obtain device object


                                  Device dev = (Device)e.nextElement();


                                  list4.add("Device Name:"+dev.getName());

                                  list4.add("Device Type:"+dev.getType());

                                  list4.add("User Id:"+dev.getUserId());

              if (dev.isEnabled()) {





              private void send (Device dev) throws Exception


                      if (this.optforfullsynchRadio.isSelected()==true)//this is a command that forces the mobile device to sync, this means that the guy

              in the office presses a button and the device starts to sync, its server initiated sync.

                      {send (dev, synchserver,"");}

                      else if (this.optforupdateclientRadio.isSelected()==true)

                      {send (dev, UpdateDMC,"");}//this forces the client to update itselfe

                       else if (this.optforinstallRadio.isSelected()==true)

                      {send (dev, Installcmd, jTextField16.getText().trim());}




              private void send (Device dev, Command cmd, String params) throws Exception


                      // Create DeviceCommand object from 'Command' object

                      DeviceCommand dc = new DeviceCommand (cmd, dev);

                      if (params.compareTo("") != 0)

                      { dc.setParameters (params);


                      // Send DeviceCommand object to the device


                     // dc.send (DeviceCommand.HIGH_PRIORITY,null );//

                      list4.add( dc.toString());


              private void  SendCommands (User user) throws Exception


                      // Retrieve the instance of DeviceManager


              DeviceManager dm = DeviceManager.getInstance();

              if (this.optforfullsynchRadio.isSelected()==true)

              {this.ForceInstall = dm.getCommand ("ForceInstall");}

              else if (this.optforupdateclientRadio.isSelected()==true)

              {this.UpdateDMC = dm.getCommand ("UpdateDMC");}

              else if (this.optforinstallRadio.isSelected()==true)

              {this.Installcmd = dm.getCommand ("Install");}


              the update, install commands exist already in olite. the full sync you will have to create it yourself in the webtogo and then all users must get it

              with an update.

              create an otl file e.g. fullsync.otl and write inside

              <c:set var="beg" value="${System.Date()}"/>

              <c:set var='exe' value="\\ORACE\\APPS\\fullsync.EXE"/>

              <c:set value="${System.Execute (exe)}"/>

              then create a small application fullsync.exe that syncs. basically what you do is

              1)the user in the office presses a button

              2)olite sends a command to the device, if the device is offline it queues the command

              3) the device gets the command. the command says "run that exe"

              4)the device runs the exe. the exe syncs in the background while the device user is doing his job

              5)device gets synced .(this is how server initiated sync works)






              so this is all, how you add,update,remove user, add user to group, send command to device, data subsetting etc

              • 4. Re: using api to create new users


                    Can you please give me a link to download the Java API?


                Thank you


                • 5. Re: using api to create new users

                  you are probably refering to

                  import oracle.lite.sync.Consolidator;

                  import oracle.lite.resource.Device;

                  import oracle.lite.resource.User;

                  import oracle.lite.resource.dm.Command;

                  import oracle.lite.dm.DeviceManager;

                  import oracle.lite.resource.ResourceManager;

                  import oracle.lite.resource.Device;

                  import oracle.lite.resource.dm.DeviceCommand;


                  from what i see in my project i just included

                  olite40.jar, olitejdbcpj40.jar

                  make a search in your olite server in the c:\ they are there in a folder (somewehere)


                  for 10gr3 there is the


                  where if you go for example inside the


                  you will see about


         Subscribing Users to a Publication


                  Subscribe the users to a publication using the createSubscription function. The following creates a subscription between the S11U1 user and the T_SAMPLE11 publication:


                  consolidatorManager.createSubscription("T_SAMPLE11", "S11U1");


                  similarly about the other points of creating users etc



         Create the Mobile Server User

                  Use the createUser method of the MobileResourceManager object to create the user for the publication.

                  1. Create the MobileResourceManager object. A connection is opened to the Mobile Server. Provide the schema name, password, and JDBC URL for the database the contains the schema (the repository).
                  2. Create one or more users with the createUser method. Provide the user name, password, the user's real name, and privilege, which can be one of the one of the following: "O" for publishing an application, "U" for connecting to Web-to-Go as user, or "A" for administrating the Web-to-Go. If NULL, no privilege is assigned.


                    Always request a drop user before you execute a create, in case this user already exists.
                  3. If you want members to be created for this device, perform the tasks described in Section, "Create Member Users for Sharing Application and Data on Device".
                  4. Commit the transaction, which was opened when you created the MobileResourceManager object, and close the connection.
                  MobileResourceManager mobileResourceManager = new MobileResourceManager(CONS_SCHEMA, DEFAULT_PASSWORD, JDBC_URL); mobileResourceManager.createUser("S11U1", "manager", "S11U1", "U"); mobileResourceManager.commitTransaction(); mobileResourceManager.closeConnection(); 
                  • 6. Re: using api to create new users

                    i another point it says something like

                    i also see it says

                    Use the Resource Manager APIs to..blablabla.. See the oracle.mobile.admin.MobileResourceManager in the Oracle Database Mobile Server JavaDoc, which is located off the ORACLE_HOME/Mobile/doc/index.htm page.


                    so you have the jars in your server already, just start a java project (for instance netbeans) include the jars for each operation and you are ready to go

                    • 7. Re: using api to create new users

                      i can send you a sample project just email me at billaras1234@hotmail.com

                      (your email is private here so i dont see it so i can send it to you)


                      my sample project is kinda sloppy but it gets the work done (as far as i remember:)   )