Thursday, November 6, 2014

How to get a static IP address in an Oracle VirtualBox VM

You probably know that all Oracle software is free to download and most come with a developer license. This means that you can use full versions of products to develop your applications.

Installing the software could be a bit difficult especially when you are trying new programs.
Therefore Oracle releases VirtualBox images witch contain complete installed servers with e.g. Oracle 12c and Application Express pre-installed.

Follow these links to the pre-build VM's:
Pre-Built Developer VMs (for Oracle VM VirtualBox)
Database Virtual Box Appliance / Virtual Machine (my current favorite)

When you start using Oracle VirtualBox images the need for more grows fast. In a short time you probably have multiple VM's with different Oracle versions.

Connection to these images starts becoming a bit of a problem because the images get their IP address from a DHCP server, embedded in the VirtualBox software. The first VM started gets the first address available, the second the next and so on. So if you start the VM's in a different order, your tnsnames entries won't point to the right databases anymore.

It's time to configure the virtual machines to have a static IP address. In this blog I will explain how you can do this.

Add or change the virtual network interface adapter

Open the VirtualBox software and edit the settings of the virtual machine you want to assign a static IP address to. It has to look something like this:


We use the virtual host-only adapter that was installed on the host by installing the VirtualBox software. This adapter has a private IP range and we are free to chose any IP address we want.


Add or change the network interface inside the virtual machine

Next, we have to start the virtual machine and add the network interface in the virtual machine. If it is already present we need to change the settings of it.

In the virtual machine settings we added network adapter 2 which is called eth1 inside the virtual machine. Login to the virtual machine and check the network settings with this Linux command:

cat /etc/sysconfig/network-scripts/ifcfg-eth1
If the file is not present we can copy the settings from the ifcfg-eth0 file:

cp /etc/sysconfig/network-scripts/ifcfg-eth0 /etc/sysconfig/network-scripts/ifcfg-eth1

Be aware to change the hardware address after the copy. First we get the hardware address:

ip addr show dev eth1 | grep link/ether | awk '{ print $2 }'

We will use the output of this command in the ifcfg-eth1 file.

Edit the network configuration file for adapter 2 (ifcfg-eth1) with your favorite text editor (e.g. vi). Change the file until it looks like this, put your own mac address in the HWADDR line:

DEVICE=eth1
IPADDR=192.168.56.10
NETMASK=255.255.255.0
NETWORK=192.168.56.0
PREFIX=24
GATEWAY=192.168.56.1
BOOTPROTO=none
ONBOOT=yes
HWADDR=08:00:27:a7:5b:1d

You can adjust IP addresses and devices as you wish. But keep in mind that the DHCP server range starts with IP 192.168.56.101. You should not use IP addresses above 100.

To make these settings work, restart the network:

/etc/init.d/network restart

And voilĂ ! You can reach your server on its static IP address!

Thursday, February 21, 2013

'Page Unload' triggers too late

Well... too late is a bit odd to say. Because it does NOT triggers too late, it triggers when the page is unloaded!

You can define a dynamic action which reacts on the 'Page Unload' trigger like this:



Most of the times very useful but say, in the hypothetical situation, you want to save your form data when the user presses log off (or the nice button with the little cross in the top corner of their browser window) it doesn't work quite well.

And that has all to do with sessions. Once you logged off you immediately are being directed to the new log on window with a new session ID and the event cannot be handled correctly anymore.
Not to speak of when you close the browser window.

So what's next?

In  APEX 4.2 it is possible to react on a custom event. So should it be possible to react on an event triggered by the 'window' object? Yes it should!

Let's change the event type in the example to 'Custom':


In my opinion the 'Custom Event' field is placed to high and it should be placed underneath the 'DOM Object' field. So let's start with the 'Selection Type'...
You can choose all the known types e.g. item, button, region etcetera. In my example I will use the 'DOM Object'. As an object I will choose 'window' and as a 'Custom Event' the 'beforeunload' event is used.

The beforeunload trigger possibly will fire to often in this example (reload, leave, submit, close) so you can use a JavaScript condition if you want it to fire only in the right situation.

It works like a charm for me :), hope it helped you too.



Tuesday, February 12, 2013

About Password Expiration in Oracle Database 11g

In the Apex Installation Guide you will find the following paragraph:

"In the default profile in Oracle Database 11g, the parameter PASSWORD_LIFE_TIME is set to 180. If you are using Oracle Database 11g with Oracle Application Express, this causes the password for APEX_PUBLIC_USER to expire in 180 days. As a result, your Oracle Application Express instance will become unusable until you change the password.

To prevent this behavior, create another profile in which the PASSWORD_LIFE_TIME parameter is set to unlimited and alter the APEX_PUBLIC_USER account and assign it to the new profile."

Of course with a little help from google you can find out how to do this. I summarized it for you:

First let's see what the limits of the default profile (or the profile of your APEX_PUBLIC_USER) are:
select resource_name
      ,limit
  from dba_profiles
 where profile = 'DEFAULT';
It will result in something like this:
RESOURCE_NAME                    LIMIT
-------------------------------- -------------------------------------
COMPOSITE_LIMIT                  UNLIMITED
SESSIONS_PER_USER                UNLIMITED
CPU_PER_SESSION                  UNLIMITED
CPU_PER_CALL                     UNLIMITED
LOGICAL_READS_PER_SESSION        UNLIMITED
LOGICAL_READS_PER_CALL           UNLIMITED
IDLE_TIME                        UNLIMITED
CONNECT_TIME                     UNLIMITED
PRIVATE_SGA                      UNLIMITED
FAILED_LOGIN_ATTEMPTS            10
PASSWORD_LIFE_TIME               180
PASSWORD_REUSE_TIME              UNLIMITED
PASSWORD_REUSE_MAX               UNLIMITED
PASSWORD_VERIFY_FUNCTION         NULL
PASSWORD_LOCK_TIME               1
PASSWORD_GRACE_TIME              7

There are two options. First you can change the default profile, but the profile of the other users will change accordingly and that may be a security vulnerability. But this is how you do it:
alter profile default limit
   password_life_time unlimited;

Second, and my favorite, add a new profile and link it to the APEX_PUBLIC_USER user:
create profile apex_public limit
   password_life_time unlimited;

alter user apex_public_user
   profile apex_public;
The first query will create a new profile with all limits to default except the password_life_time. The second one changes the profile of the APEX_PUBLIC_USER.

And... don't forget to change the profile for your APEX_LISTENER and APEX_REST_PUBLIC_USER.

Thursday, October 4, 2012

What version do I have?


What if you quickly want to see what APEX version you're running...
Just login as system and use the following query:

select comp_name, version from dba_registry;

Not only the APEX version is show but also other version information of the database.

Monday, October 1, 2012

Interactive Report 100% width


Did you know that you can make an interactive report fill up all horizontal space on the page very easily? You can do this by adding the following code to the HTML header section of the page:

<style type="text/css">
  .apexir_TOOLBAR_OPEN {width:100%;}
  #apexir_TOOLBAR {width:100%;}
  #apexir_DATA_PANEL table,
  .apexir_WORKSHEET_DATA {width:100%;}
</style>

If you set your report template to 'Borderless Region' it should work immediate.

Thursday, September 27, 2012

Useful content

My blog has just been started. There is no useful content at this moment.

But within a few weeks there will be. My goal is to blog at least once a month.