December 20, 2016

How to Export or Import oracle database

Oracle database is providing some command line tools to import or export any schema , data of a schema or the total oracle database from one to another. These tools come along with the oracle database installation by default.

Exporting:
There are two command tools to export database exp and expdp.

exp command:
Open the console and give the exp command on the command prompt. It will prompt for information like username, password, export filename and path etc as below.

Example of using oracle database command "exp"

And also it will show few options like below. You can export entire database or only users/schemas or only the tables. You can also mention, whether you want to export permission and data inside the tables also.


 After providing all these information, it will start exporting the database. After finishing it you can observe a statement like "Export terminated successfully"


Instead of following the above step by step procedure, we can give all this in a single command which will do the same. Below is the example of the command.

Ex:  Exp userid=mytestings/welcome1@xe file=d:\mydump.dmp



expdp command:
Another tool to export database is expdp command. Which works like exp command but it is more powerful. Below is the example to use this command.

expdp mytestings/welcome1 dumpfile=mydump_1.dmp logfile=mydump.log


Importing:
There are two command tools to import database from the .dmp files are imp and impdp.
These two works like the above export commands.

Below are the syntax and example to use imp command.
Syntax:
imp userid/password@Connect_identifier fromuser=user_name_you_have_data_unloaded_from touser=new_user_name file=Path_to_*.dmp file

Ex: imp testuser/welcome1@xe fromuser=mytestings touser=testuser file=D:\Data\MYDUMP.dmp

The result would look like as below.


Below is the example to use impdp command.

impdp mytestings/welcome1@orcl TABLE_EXISTS_ACTION=REPLACE dumpfile=MYDUMP.dmp

Instead of passing options to the command line, we can create a .par file and give all these properties in that file and pass that file to the command as below. This .par file option is available for both impdp and expdp commands but not imp and exp commands.

impdp sccinternal/welcome1@orcl parfile=impdata.par

Sample .par file look like as below.

schemas=mytestings
logfile=importlog.log
dumpfile=MYDUMP.dmp
TABLE_EXISTS_ACTION=REPLACE




December 6, 2016

Error: [ADF security error] The method getDBTransaction on class oracle.jbo.server.EntityImpl is not permitted

[JDev 12.2.1.0]

I have created an EntityObject from database table and assigned an expression to its key attribute to get the value from a database sequance (See this post to know how to assign a db sequence to a property in entity object ). But while building the project, I got the below error.

Error(11,53): [Static type checking] - [ADF security error] The method getDBTransaction on class oracle.jbo.server.EntityImpl is not permitted.
 @ line 11, column 53. Locations.bcs D:\Application2\Model\src\model Model.jpr


Which means that the entity is not trusted the expression changes. To avoid this issue,

  • Go to the source of the entity object xml file 
  • Search for the tag "TransientExpression"
  • Check the value of the attribute "trustMode"
  • If it is "untrusted", change it to "trusted"
  • Now rebuild the project
The above change solved my issue .






November 22, 2016

TypeError: h.apply is not a function

This is a Knockout JS error. I faced this issue when I am trying to invoke click action of a link created. My link statement is like below.

<a data-bind="attr:{id:Reqid},text: Title,click: $('#popup1').ojPopup('open', '#btnTitle')"></a>

And on click of this link, I am getting the below error.

TypeError: h.apply is not a function

This is because the click handler needs to be wrapped within a function. Below updated statement resolved the issue.

<a data-bind="attr:{id:Reqid},text: Title,hover: function(){$('#popup1').ojPopup('open', '#btnTitle')}"></a>

November 1, 2016

How to open device camera or picture gallery from Oracle MAF app

MAF provides a device feature method getPicture() to open the device camera or picture gallery. You can create binding to it if you want to open camera on the app. But if you want to handle this from java code in MAF, then check the below post.

Below is the code should be used to access the camera from the java code in MAF.

DeviceManager dm = DeviceManagerFactory.getDeviceManager();
String result=   dm.getPicture(75, dm.CAMERA_DESTINATIONTYPE_DATA_URL, dm.CAMERA_SOURCETYPE_CAMERA, false, dm.CAMERA_ENCODINGTYPE_PNG, 300, 250);

This method returns a string value with either base46 encoding string or the file path of the image based on the given destination type.

Syntax of the method is:
getPicture(int quality, int destinationType, int sourceType, boolean allowEdit, int encodingType, int targetWidth, int targetHeight) 

Where

quality: Quality of saved image
destinationType: Type of the return value whether it is base64 encoding string or file path. For base64 use 0=DESTINATIONTYPE_DATA_URL or for file path use 1 = DESTINATIONTYPE_FILE_URI
sourceType: What is the source of the picture whether it is device camera or photo gallery. For gallery use 0=CAMERA_SOURCETYPE_PHOTOLIBRARY or for camera use 1=CAMERA_SOURCETYPE_CAMERA
allowEdit: Allow simple editing of image before selection
encodingType: the encoding of the returned image file. Select 0 = CAMERA_ENCODINGTYPE_JPEG for JPEG image or 1 = CAMERA_ENCODINGTYPE_PNG for PNG image
targetWidth: Width in pixels to scale image
targetHeight: Height in pixels to scale image

Note: you can not test camera in iOS Simulator or Android Emulator. The camera can be tested only on the device, but you can test the gallery in the Simulator or Emulator. To check if the running device is Simulator or Emulator, you have to give a condition like,

if (dm.getName().indexOf("Simulator") != -1)  // For iOS Simulator
if (dm.getName().indexOf("sdk") != -1)            //For Android Emulator

October 19, 2016

WindowManager: android.view.WindowLeaked: Activity has leaked window

While developing an android mobile app, I received this error.
In the mobile app, on click of back button, a dialog will be opened with few buttons including "Exit". On click of exit, I have given (Activity context).finish(); but it is throwing the below error.


WindowManager: android.view.WindowLeaked: Activity <app package> has leaked window com.android.internal.policy.impl.PhoneWindow$DecorView{45500950 V.E..... R....... 0,0-640,929} that was originally added here
at android.view.ViewRootImpl.<init>(ViewRootImpl.java:368)
at android.view.WindowManagerGlobal.addView(WindowManagerGlobal.java:252)
at android.view.WindowManagerImpl.addView(WindowManagerImpl.java:69)
at android.app.Dialog.show(Dialog.java:286)
at android.app.Activity.onKeyUp(Activity.java:2204)
at android.view.KeyEvent.dispatch(KeyEvent.java:2664)
at android.app.Activity.dispatchKeyEvent(Activity.java:2434)



This error occurred due to improper closing of the dialog box before exiting the app. So, the solution I found is to dismiss the dialog box before calling finish() method.

September 5, 2016

Social All In One - One app solution for all your social network activities

I have developed another android app named as "Social All In One" which is a one app solution for all your social activities. No need to install each app like Facebook, Twitter, Linkedin, Pinterest and Instagram etc. This app supports all popular social networking sites.

It will become the primary Social Hub on your phone.

This app supports social networks including Facebook, Twitter, Linkedin, Google+, Instagram, Badoo, Disqus, Flickr, My life, Hi5, Reddit, Vine, VK, Wayn, xing, We heart it, Livejournal, My heritage and more.

Click here for more details.


July 28, 2016

Reverse 2048

Reverse 2048  - A new android app from me.

This is a fun, addictive and a puzzle board game. It is a cool variant of traditional 2048 puzzle game.

The challenge is to reach from the #2048 tile to #1 tile. When tile with number 1 is created, the player wins the game.

Click here for more details of the app.


June 28, 2016

How to invoke HTTP methods like PUT,PATCH and DELETE using HttpURLConnection

     I am invoking REST web services using HttpURLConnection. Few of the rest services have operations like PUT, PATCH, and DELETE. While passing these methods in setRequestMethod() of HttpURLConnection object, I am getting the below error in response.

java.net.ProtocolException: Invalid HTTP method: PATCH

     To avoid this error and to let the HttpURLConnection execute these methods, there is a workaround which is to override the http method we are invoking. And the procedure to do it is,
  • Invoke any accepted http method like GET or POST
  • Pass the new method value to the header parameter "X-HTTP-Method-Override" to Override the method 
Below is the example: 
            URL url = new URL(mcsPatchAPIURL);
            HttpURLConnection conn = (HttpURLConnection) url.openConnection();
            conn.setRequestMethod("POST");
            conn.setRequestProperty("Accept", "application/json");
            conn.setRequestProperty("Content-Type", "application/json; charset=utf-8");
            conn.setRequestProperty("X-HTTP-Method-Override", "PATCH");

To get an idea about these methods:

GET: To get the details of a resource
PUT: To update the existing resource
POST: To create a new resource
PATCH: To update the existing resource partially
DELETE: To delete the existing resource

May 13, 2016

Cordova Plugin is not added to Oracle MAF

Issue:
I faced an issue where I could not able to add few cordova plugins to Oracle MAF application. I could able to select the plugin but after selected, it is not added to MAF and not showing any error also.

Solution:
Check the value of the attribute xmlns of the tag plugin in the plugin.xml file under the corddova plugin folder. Generally it is

xmlns="http://cordova.apache.org/ns/plugins/1.0"

Change the value to as below
xmlns="http://apache.org/cordova/ns/plugins/1.0"

Now re-try to add the plugin to MAF.

February 29, 2016

Adding a custom css/skin file to a Oracle MAF application

When we want to apply our own css to a Oracle MAF application, we need to configure a custom css file to it. Below is the procedure to know how to add a custom css/skin file to a MAF application.
  • Right click on ApplicationController project -> select CSS File -> enter css file name. Below is the default path of the file to be created. Here my css file name is myskin.css
            /ApplicationController/public_html/resources/css/mycss.css

  • Open maf-config.xml which is under Application Resources and check the skin family and version
         Ex
             <skin-family>mobileAlta</skin-family>
             <skin-version>v1.4</skin-version>

  • open maf-skins.xml which is under the project "ApplicationController" and create an xml entry like below
        <?xml version="1.0" encoding="UTF-8" ?>
         <adfmf-skins xmlns="http://xmlns.oracle.com/adf/mf/skin">
         <skin-addition id="s1">
         <skin-id>mobileAlta-v1.4</skin-id>
         <style-sheet-name>resources/css/myskin.css</style-sheet-name>
         </skin-addition>
         </adfmf-skins>

Where <skin-id> is the combination of skin-family and skin-version of maf-config.xml file seperated by "-" and enter the css file path for <style-sheet-name>.

February 3, 2016

How to integrate or configure InAppBrowser Cordova plugin in Oracle MAF

I have created a video to show how to integrate a Cordova plugin in Oracle MAF to show InAppBrowser in a mobile app. Click here to watch the video. This video also shows the procedure to integrate any other Cordova plugin with the Oracle MAF.

The MAF version 2.1 with JDeveloper 12c is used in this example.



Below are the steps to integrate the InAppbrowser Cordova plugin in Oracle MAF.
  1. Download the inappbrowser cordova plugin from https://cordova.apache.org to your machine
  2. Create a MAF application in JDeveloper
  3. Unzip the downloaded inappborwser plugin in your machine
  4. Copy and paste the plugin folder under the ViewController project folder in the MAF application
  5. Register or Configure the plugin in MAF application's maf-application.xml
  6. White list the domain you want to open in the app browser
  7. Create a java class and write a method to invoke inappbrowser api
  8. Create a button in amx page to bind the method
  9. Select the simulator and run the app
  10. Inappbrowser is ready. On click of the link in the app, a browser will be opened in the app with the given url. You can also choose to display extra buttons and navigation on this browser by changing the parameters passed in the java script api.

January 7, 2016

Typing Hero - Challenge your typing skills

I developed another android app "Typing Hero" to test and challenge your typing skills.

Typing Hero is a fun and learn app where you can increase your typing skills and also have fun by challenging each level with your friends in the app.

Typing Hero has different types of typing difficulties like Beginner, Medium, Hard and Harder. Each of these difficulties has several levels except Harder. Harder has only one level which gives more difficult lines to type every time which makes you expert in typing.

Click here to know more about the app.

Click here to download the app from play store.

To know other apps developed by me, visit Sonu Appz.