Friday, October 16, 2015

How to Install TigerVNC

Install TigerVNC in RHEL or OEL


The following are quick and easy steps for installing VNC server in RHEL/OEL Linux distros.

Installation Steps


yum install tigervnc-server

Edit the vncserver config file:

vi /etc/sysconfig/vncservers

Add usernames to config file:

[...]
VNCSERVERS="2:weblogic 3:johnsmith"
VNCSERVERARGS[2]="-geometry 1200x1024 -nolisten tcp -localhost"

Login as the user you want VNC in as and then set the password using vncpasswd command.

Adding Gnome/KDE


Run the below commands to install GNOME/KDE desktop environments.

yum groupinstall "Development Tools"

yum groupinstall "X Window System" "Desktop"

yum groupinstall "GNOME Desktop Environment"

Tuesday, June 17, 2014

Fixing "This desktop does not support the requested display protocol." error in VMWare View Client in OSX Mavericks

Earlier I couldn't connect to a Microsoft XP remote desktop via VMware View Client in OSX Mavericks even though I could connect fine from a Windows 7 machine (using VMware View Client).

I managed to fix it by installing "Microsoft Remote Desktop Connection for Mac" from here:
http://www.microsoft.com/en-au/download/details.aspx?id=18140

Note: If you google the error, you will get a wide variety of causes/triggers for the error. In my case not having this MS remote connector was the cause.


Friday, April 11, 2014

Oracle APEX, set value of shuttle via javascript


In Oracle APEX Javascript API, you would typically set the value of page item by 

$x('P1_ITEM').value = 5;

This would work with textfields, select list. But for more complex input items like shuttle, it would not work.

If one examines an APEX shuttle item with Firebug or Chrome Dev tools, one can see its composed of 2 items fields, suffixed with "_LEFT" and "RIGHT".


Solution is to use apex.item("<<name of item>>")>setValue(<<value>>); which takes into consideration the item type.

apex.item( "P1_ITEM" ).setValue( "10" );

You can read more about apex.item in the Oracle documentation for APEX's JavaScript API:
http://docs.oracle.com/cd/E37097_01/doc/doc.42/e35127/javascript_api.htm#AEAPI29494

Saturday, April 5, 2014

Upgrade Java to 1.7 in OEL

1) Look-up up packages 

yum search java | grep 'java-'
This system is not registered with ULN.
You can use up2date --register to register.
ULN support will be disabled.
java-1.6.0-openjdk.x86_64 : OpenJDK Runtime Environment
java-1.6.0-openjdk-demo.x86_64 : OpenJDK Demos
java-1.6.0-openjdk-devel.x86_64 : OpenJDK Development Environment
java-1.6.0-openjdk-javadoc.x86_64 : OpenJDK API Documentation
java-1.6.0-openjdk-src.x86_64 : OpenJDK Source Bundle
java-1.7.0-openjdk.x86_64 : OpenJDK Runtime Environment
java-1.7.0-openjdk-demo.x86_64 : OpenJDK Demos
java-1.7.0-openjdk-devel.x86_64 : OpenJDK Development Environment
java-1.7.0-openjdk-javadoc.x86_64 : OpenJDK API Documentation
java-1.7.0-openjdk-src.x86_64 : OpenJDK Source Bundle
cairo-java-devel.i386 : Compressed Java source files for cairo-java.
cairo-java-devel.x86_64 : Compressed Java source files for cairo-java.
glib-java-devel.i386 : Compressed Java source files for glib-java.
glib-java-devel.x86_64 : Compressed Java source files for glib-java.
java-1.4.2-gcj-compat.x86_64 : JPackage runtime scripts for GCJ
java-1.4.2-gcj-compat-devel.i386 : JPackage development scripts for GCJ
java-1.4.2-gcj-compat-devel.x86_64 : JPackage development scripts for GCJ
java-1.4.2-gcj-compat-javadoc.x86_64 : API documentation for libgcj
java-1.4.2-gcj-compat-src.x86_64 : Source files for libgcj
libgconf-java-devel.i386 : Compressed Java source files for libgconf-java.
libgconf-java-devel.x86_64 : Compressed Java source files for libgconf-java.
libglade-java-devel.i386 : Compressed Java source files for libglade-java.
libglade-java-devel.x86_64 : Compressed Java source files for libglade-java.
libgnome-java-devel.i386 : Compressed Java source files for libgnome-java.
libgnome-java-devel.x86_64 : Compressed Java source files for libgnome-java.
libgtk-java-devel.i386 : Compressed Java source files for libgtk-java.
libgtk-java-devel.x86_64 : Compressed Java source files for libgtk-java.
libvte-java-devel.i386 : Compressed Java source files for libvte-java.
libvte-java-devel.x86_64 : Compressed Java source files for libvte-java.

2) Install the package:
yum install java-1.7.0-openjdk.x86_64

Monday, March 24, 2014

Install Oracle REST Data Services for Oracle Apex in Apache Tomcat 7

1) Download Oracle REST data services from http://www.oracle.com/technetwork/developer-tools/rest-data-services/downloads/index.html

2) Unzip the content of the ZIP directory
3) Rename the ords.war to apex.war if you want the URL in the format of http://hostname/apex
mv ords.war apex.war

4) Before you configure the WAR file you will need to specify where the config files should be kept. Create a directory where you want the config files to be kept. Suppose its in /home/oracle/apex_config

5) Run the following:
java -jar apex.war configdir "/home/oracle/apex_config"

6) Next run the setup, it will write the config files to directory specified in parameter in step 5 above:
java -jar apex.war setup

7) Copy this apex.war file to <<tomcat home>> /webapps directory

8) Copy the Apex Images to <<tomcat home>>/webapps/images directory and rename this directory to i so the path to images directory is 
<<tomcat home>>/webapps/i

9) Startup Tomcat

Wednesday, December 4, 2013

Resolving weblogic.store.PersistentStoreException:...."_WLS_AdminServer" cannot open file _WLS_ADMINSERVER000000.DAT. error


In Weblogic 10.3.5, if you get the following error during startup:



> <Store> 045> <The persistent store "_WLS_AdminServer" could not be deployed: weblogic.store.PersistentStoreException: [Store:280105]The persistent file store "_WLS_AdminServer" cannot open file _WLS_ADMINSERVER000000.DAT.

You can try fix it by navigating to:
 
/u01/weblogic/Oracle/Middleware/user_projects/domains/<<Domain_name>>/servers/AdminServer/data/store/default/

directory and delete the _WLS_ADMINSERVER000000.DAT fIle.

This action is detailed out in Oracle Support doc ID:  957377.1

 After deleting the file, try restart the server again. 


 

Wednesday, November 20, 2013

Oracle Database: unexpire schema or fix ORA-28001 without changing the password

In Oracle Database, to unexpire schemas, you will need to issue the command as SYS/SYSTEM:

ALTER USER <USERNAME> IDENTIFIED BY <PASSWORD>

For this to happen you will need to know the password of the user you are trying to "unexpire". There are situations however where we do not know the password of the schema we are trying to unexpire.


A work around is retrieving the hashed password of the schema and issue the ALTER USER statement in slightly different manner:

Using the SCOTT/tiger example below: 

STEP 1: Retrieve the hashed password of the expired schema

Connect as SYSDBA and run the query: 

SQL> select password from sys.user$ where name = 'SCOTT';

PASSWORD
------------------------------
F894844C34402B67


STEP 2: Run the ALTER USER command as below:

SQL> ALTER USER SCOTT IDENTIFIED BY VALUES 'F894844C34402B67';

If account is locked you may need to run the following as well:

ALTER USER SCOTT ACCOUNT UNLOCK;

Saturday, August 10, 2013

Oracle Apex Tabular Form: Delete unsaved rows without submitting

A common shortfall in Tabular Form functionality in APEX (amongst many) is that when you add a couple of rows and you wish to delete one without saving the form, you will end up losing the whole lot of rows entered.

This piece of code will help you avoid the problem. Put this in page header and in the DELETE button's attribute, set type as URL and javascript:delete_rows(); as target.

The way it works, if the checked row wasn't saved and it will be removed without page submission, otherwise the page will be submitted to remove it via normal mechanism.

<script language="JavaScript" type="text/javascript">
    function delete_rows()
    {
        var need_submit = 0;
        $("[name='f01']").each(function(){

        if($(this).attr("checked"))
        {
            if(this.value == 0) // new row, not saved. Checkbox value is 0
            {
                $(this).closest("tr").remove();
            }
            else    // row was saved before, need to be removed via page submission.
                need_submit = need_submit + 1;
           
        }

        });
       
        if(need_submit > 0)    // require submission?
            apex.submit('MULTI_ROW_DELETE');
           
        addTotal();   

    }

</script>

Saturday, November 10, 2012

Oracle Apex - Dynamically Color Text field

It is often useful to highlight certain fields when certain (usually incorrect) values are entered as a form of on the fly validation. 

Suppose you had a fairly large form with many fields many of which only accept numbers. It would be much more user friendly if you could alert end-users to incorrect values as they enter it, rather than let them submit and have a big list of invalid entries to sift through.



1) Put the following code in page header.

<script language="JavaScript" type="text/javascript">

function setCol(pThis)
{
var vv = $v(pThis);
var cls = '#'+pThis;
if(isNaN(vv))
{
$(cls).css("background-color","red");
}
else
{
$(cls).css("background-color","white");
}
}


</script>

2) Create Dynamic Action with following configuration:
  1. Type Advanced (for pre-4.2)
  2. Event: change
  3. Selection Type: item
  4. Item(s): P1_ENAME, P1_MOB (comma seperate the list of items)
  5. True Action: 
    1. Action: Execute Javascript Code
    2. Code: setCol(this.triggeringElement.id);
  6. Affected Items:
    1. Pick the items in #4 above.

What this does is basically highlight textfield when non-numeric characters are entered (isNAN). 

Here is how it should look like if implemented properly. You can take this and do more fancy stuff like validating against regex. 

http://apex.oracle.com/pls/apex/f?p=21796:1

Saturday, October 27, 2012

Oracle - Move schema from one tablespace to another


Starting from 11G, Oracle offers a much simpler way to migrate schema for tablespaces with Data Pump utility. Previously you would have to export the schema and then drop the user re-import the schema and then rebuild all the indexes.

With Data Pump the process of switching tablespace is much simpler.

STEP 1: Export the schema using datapump
expdp system/system_password SCHEMAS=MY_SCHEMA DIRECTORY=DATA_PUMP_DIR DUMPFILE=MY_SCHEMA.dmp LOGFILE=expdp.log

Review the log to ensure the export is done properly.

STEP 2: Drop the user from database
 DROP USER MY_SCHEMA CASCADE;

STEP 3: Import the schema with REMAP_TABLESPACE
impdp system/my_schema SCHEMAS=MY_SCHEMA REMAP_TABLESPACE=SYSTEM:MY_SCHEMA_TBSPACE DIRECTORY=DATA_PUMP_DIR DUMPFILE=MY_SCHEMA.dmp LOGFILE=impdp.log


STEP 4 : Verify Tablespace Change & Validity of Objects

Check for default tablespace by running:
select username, default_tablespace from dba_users;

Also check if all objects are valid, if not compile them
SQL> select owner, status from dba_objects where upper(owner)='MY_SCHEMA';

Check the indexes:
select index_name, status from all_indexes where status ='UNUSABLE';

For more information, check out the white paper on Data Pump:

Quick Start Guide:
http://www.oracle.com/technetwork/issue-archive/2009/09-jul/datapump11g2009-quickstart-128718.pdf

Documentation:
http://docs.oracle.com/cd/B12037_01/server.101/b10825/dp_import.htm

Sunday, September 23, 2012

Creating database backups using exp & and crontab

The following is a neat little script that will allow you to create logical backups (and remove old ones) of your schema in the same file system of the database.


ORACLE_BASE=/u01/app/oracle
export ORACLE_BASE
ORACLE_HOME=/u01/app/oracle/product/11.2.0/xe
export ORACLE_HOME
ORACLE_SID=XE
export ORACLE_SID
PATH=$ORACLE_HOME/bin:$PATH
export PATH

BKUP_DEST=/home/rode/cbackups
find $BKUP_DEST -name 'backup*.dmp' -mtime +10 -exec rm {} \;



cd /home/rode/cbackups && /u01/app/oracle/product/11.2.0/xe/bin/exp schema/password FILE=backup_`date +'%Y%m%d-%H%M'`.dmp


You will need to change the bits highlighted in orange with paths of your system. The script starts by exporting necessary paths, then removes any old backups greater than 10 days before using the exp utility to create the backup.

To set it up, follow these instructions: 
  1. Create a directory where the backups will be stored. In my case it is: /home/ai/cbackups
  2. Open vi and save the scripts (after replacing bits in orange with your own setup) in your home directory as say: /home/ai/backup_script.sh
  3. Next, run crontab -e to set up a new cron job.
  4. Add an entry like:
    10 0 * * * /home/ai/backup_script.sh

Above the the script will run every 10 minutes past midnight. Check out this link on how to schedule crontab: http://www.adminschoice.com/crontab-quick-reference


You may opt (and better idea) to use data pump instead as it supercedes the export/import utilities and if exporting involves lots of data. Check this document on how to use data pump:
http://www.oracle.com/technetwork/issue-archive/2009/09-jul/datapump11g2009-quickstart-128718.pdf

Sunday, September 16, 2012

Resolving ORA-01940 error

This post shows how to get around ORA-01940 error. You typically get this error when the schema you are trying to drop is connected to something (presumably another application).

The following script will allow you to kill the sessions and drop the schema.


set serveroutput on
DECLARE
  cursor c1 is select SID, SERIAL# from v$session where username = '<schema_name';
BEGIN
FOR rec IN c1 loop
EXECUTE IMMEDIATE 'alter system kill session '''||rec.SID||','||rec.SERIAL#||'''';
end loop;
DROP USER <SCHEMA_NAME> CASCADE;
END;

Friday, July 20, 2012

Oracle Apex: Adding Up Tabular Form Column Values

Often with tabular form we get the requirement to tally up the total of one of the columns as user add/edit/delete rows of data.

In this post I'll show an easy & efficient way to achieve this using Javascript.

Step 1
Get your Javascript function to add-up the total ready. I have created a simple function which you can customise for your application. You will need to know the ID of the tabular form element you are trying to add.

All editable APEX tabular forms that are ID'ed like f0x_000x. You can find them out by using Firebug (chrome, firefox) or IE Developer Tool by hitting F12 as below. 


In my case I need add up the total in Salary column as I add rows or edit entries and add it to the Total Salary text field above the tabular form.

So here is the script. Find out the ID of your field and update the italics part. 

<script language="JavaScript" type="text/javascript">

 function addTotal()
 {
  var items = document.getElementsByName("f07"); // Tabular form column to add up
  
  $total = 0;
  $itemValue = 0;
  for (var i = 0; i < items.length; i++)
  {  
   // if non-numeric character was entered, it will be considered as 0, 
   // isNaN returns true if anything but number was entered
   if(isNaN(items[i].value) || items[i].value == null || items[i].value == "")
    $itemValue = 0;
   else
    $itemValue = parseFloat(items[i].value); // convert to number
   
   $total =$total+ $itemValue; // add up
  } 
  
  // $x sets the text field to be updated to the column total just calculated
  $x('P5_TOTAL_SALARY').value = $total;
 }
</script>

STEP 2. Test out the javascript.

Its a good idea to make sure your code works before putting it page attribute. So open up Firebug, go to the console tab and copy & paste the body of the function (everything in between the curly braces) and hit enter. If your Total Salary textfield gets updated as below then the function is working fine. 



STEP 3. 
Go to page attribute and in HTML Header & Body Attribute enter the code above.




STEP 4.
Next in page attribute, go to Javascript tab and  and add the newly created function addTotal() to where it says Execute when Page Loads. This will ensure that columns are totaled when page is loaded.





STEP 5. 
I will wrap that tabular form with a < DIV> tag and call this addTotal() function with onkeyup event. This will update the column total on every subsequent entries. 





With these steps, you should be able to add up the total of a tabular form column.


Here is how the it should behave if you implement the above steps correctly. 
http://apex.oracle.com/pls/apex/f?p=63895:5