Quick tips

A easy way to compile many objects in Oracle database

When compiles an object that is referenced by many others, they stay invalidated until Oracle compile they again and sometimes it fails.

So, here’s a tip to compile several invalid packages, procedures and/or functions and fix this.

There is a command to compile all invalid objects under an user, the command is:

<pre class=”brush:sql”>exec dbms_ultility.compile_schema(&lt;USER&gt;);</pre>

Replace  &lt;USER&gt; for <i>user</i>, or for user name where invalid objects are.

This command is slow and not compiles objects invalidated by coding error. To find which are invalid you need runs the query below:

<pre class=”brush:sql”>
select object_name
from all_objects
where status = ‘INVALID’
</pre>

Invalid objects will be listed.


Why to use File.separator and File.pathSeparator

Java programmers knows about methods quoted in title, but many doesn’t care with them.

These methods are useful for programmer that do not knows wich characters represents file separator and path separator at OS that supports your application.

Linux/Unix, the methods File.separator and File.pathSeparator returns “/” and “.”, while in Windows, these methods returns “\” (or “\\” – escape) and “;”.

In recent case, the code below threw exception FileNotFoundException running over Linux, but not running over Windows:

String appPath = ctx.getRealPath();
String filePath = appPath + "\\" + "WEB-INF/classes/my/application/packages/";

File file = new File(filePath, "report.pdf");
OutputStream out = new FileOutputStream(file);
...

Worked in both systems after to replace “\\” by File.separator in line 2:

String appPath = ctx.getRealPath();
String filePath = appPath + File.separator + "WEB-INF/classes/my/application/packages/";

File file = new File(filePath, "report.pdf");
OutputStream out = new FileOutputStream(file);
...

Utilization of these methods, besides a good practice, is very usefull when same version of an application is running over differents operacional systems.


Fixing WordPress error “Allowed memory size of…”

I’ve just updated my WordPress to version 3.2, when update has been finished a page with error code 500 was displayed. In log file had many entry of Fatal error: Allowed memory size of 33554432 bytes exhausted

To know if it your problem too, edit file error_log in wp-admin directory and and take a look at last rows.

The following process fixed this for me, but your host server should allow sizing PHP memory at runtime.

Open and edit file wp-settings.php at root of WordPress directory and put the row bellow after “<?php”:

define('WP_MEMORY_LIMIT', '64M');

Here I’ve set up to 64MB to PHP, but how to know amount of MB to set up?

In error message, the long number means amount of bytes allocated to PHP: “Fatal error: Allowed memory size of 33554432…”. This number represents 32MB (do this calculation to converts byte in megabytes 33554432 / (1024^2) = 32).

Just set a number greater than the result in line above.


Installing .apk packages at Android SDK emulator

Sometimes our applications depends of third-part applications for tests or to access resources of emulator that aren’t available by default.

In directories of SDK, commonly in platform-tools, there is an executable called adb, with it we’ll to install third-part applications.

You will need an application (.apk). Browse internet or copy from your Android smartphone using applications like AppSaver.

- Run the emulator, you can use SDK Manager or Eclipse plugins.

- Using DOS Command (Windows) or terminal (Linux), open directory platform-tools and run commando line below:

$ adb install <.apk path>

This message will be displayed

$ adb install Application.apk
125 KB/s (1091937 bytes in 8.474s)
        pkg: /data/local/tmp/Application.apk
Success

Now, the third-part application is available at emulator menu, like have installed in your smartphone.

Agora o aplicativo estará disponível no menu do emulador. ;)

 


Setting up internet access through proxy server

Today I had a trouble in my workplace when a client application, running through a terminal (DOS prompt), not reach the server hosted in the internet, this is because the company where I work use proxy.

After some tries I found two solutions to solve my access problem: first was pass as Java parameters the proxy’s configurations.

$ java -Dhttp.proxyHost=serv -Dhttp.proxyPort=port -Dhttp.proxyUser=user -Dhttp.proxyPassword=pass  ClassJava

-Dhttp.proxyHost = IP or host name of server proxy
-Dhttp.proxyPort = Proxy port
-Dhttp.proxyUser = User
-Dhttp.proxyPassword = Password

This way the class ClassJava will have access to internet through proxy server.

Another way, was insert the settings in own class:

public static void main(String[] args){
...
System.getProperties().put("proxySet", "true");
System.getProperties().put("http.proxyHost", "serv");
System.getProperties().put("http.proxyPort", "port");
System.getProperties().put("http.proxyUser", "user");
System.getProperties().put("http.proxyPassword", "password");
...
}

proxySet = Connect, or not, through proxy server
http.proxyHost = IP or host name of server proxy
http.proxyPortt = Proxy port
http.proxyUse = User
http.proxyPassword = Password

Using this resource you can set your application to access the internet through proxy server.

I hope help you.  Bye! ;)


  • AdSense

  • Copyright © 1996-2010 André L. S.. All rights reserved.
    iDream theme by Templates Next | Powered by WordPress