Monday, July 31, 2006

Who's IP?

If we are working on a network, then how do we know the owner of the IP Address? We can using nbtstat command (if you are Windows user) to get the information about that IP. Only type this command below on your DOS prompt

nbtstat -A 172.16.3.157

And then the DOS prompt would echoing the information you entered. For example it look like this below :

Local Area Connection:
Node IpAddress: [172.16.3.87] Scope Id: []

NetBIOS Remote Machine Name Table

Name Type Status
---------------------------------------------
GIA <00> UNIQUE Registered
MIS <00> GROUP Registered
GIA <20> UNIQUE Registered
MIS <1e> GROUP Registered

MAC Address = 00-11-09-97-AC-66


It describes that the owner of this IP Address is GIA and as a member of MIS workgroup/domain.

How many hops to get your site?

Sometimes if we are going to a website, it takes a long time until the page is being loaded.
Why does this happen? It's a many reason to explain this. I'll describe one. The hops. Yes, the hops.

More and more a hops you get, more and more a time to take.
If you are a Windows users you can using tracert command and if you are a Linux users you can using traceroute command.

Type this command below on your DOS prompt :

tracert asepandria.blogspot.com

or on your Linux terminal type :

traceroute asepandria.blogspot.com

And then the DOS prompt or Linux terminal would echoing the hops of your destination site. For example, it would echoing something like this :

Tracing route to blogspot.blogger.com [66.102.15.101]
over a maximum of 30 hops:

1 <1 ms <1 ms <1 ms 172.16.1.3
2 <1 ms <1 ms <1 ms ws2.yogya-ho.melsa.net.id [202.138.229.195]
3 10 ms 7 ms 10 ms fe3-1-gw3-bdg.melsa.net.id [202.138.237.129]
4 16 ms 13 ms 7 ms fe0-3-gw-bdg.melsa.net.id [202.138.225.81]
5 74 ms 16 ms 64 ms fe1-1-gw-jkt.melsa.net.id [202.138.225.26]
6 * 91 ms 112 ms ip-240049 [202.93.240.49]
7 98 ms * 17 ms 202.93.240.18
8 44 ms 57 ms 29 ms 202.152.164.185
9 18 ms 22 ms 96 ms 202.93.46.189
10 * * * Request timed out.
11 304 ms 324 ms 230 ms 12.118.124.89
12 291 ms 279 ms 335 ms tbr1-p012101.la2ca.ip.att.net [12.122.2.250]
13 235 ms 312 ms 391 ms ggr2-p310.la2ca.ip.att.net [12.123.222.25]
14 374 ms 249 ms 269 ms so-8-1.car4.LosAngeles1.Level3.net [4.68.127.133]
15 241 ms 302 ms 266 ms ae-2-56.bbr2.LosAngeles1.Level3.net [4.68.102.161]
16 229 ms 313 ms 280 ms as-2-0.bbr2.SanJose1.Level3.net [4.68.128.157]
17 308 ms 306 ms 237 ms ae-22-52.car2.SanJose1.Level3.net [4.68.123.48]
18 251 ms 278 ms 403 ms unknown.Level3.net [209.247.202.218]
19 267 ms 234 ms 254 ms 66.249.94.227
20 346 ms 288 ms 242 ms 72.14.233.123
21 287 ms 237 ms 248 ms 66.102.15.101

Trace complete.

Friday, July 28, 2006

How to remove mysqld as a Windows service

(1) Go to the bin directory of your MySQL

cd C:\mysql\bin

(2) Type this command to remove mysqld as a windows service

mysqld --remove MySQL-4.0.26

(3) Done.

How to make mysqld as a Windows service

For a new MySQL 4.1 / MySQL 5.0 and up, if we are installing the database then mysqld would automatically installed as a windows service. But, if we are using MySQL 4.0 then we must manually installing mysqld as a windows service. How to do that ?

(1) Install your MySQL 4.0 database on your computer. For example on C:\mysql directory
(2) Choose your MySQL configuration file (my-huge.cnf, my-innodb-heavy-4G, my-large, my-medium, my-small)
(3) Copy your selected MySQL configuration file to C:\ and rename that configuration file with a new name

ren my-huge.cnf my-4.0.26.cnf

(4) Go to the bin directory of your MySQL

cd C:\mysql\bin

(5) Type this command to install mysqld as a windows service

mysqld --install MySQL-4.0.26 --defaults-file=C:\my-4.0.26.cnf

(6) Done. If you want your mysqld automatically running every your computer starting up then you must go to the Start -> Control Panel -> Administrative Tools -> Services

(7) Right click your MySQL service name on services list and choose Properties
(8) Choose Startup type: Automatic
(9) Click OK and your mysqld would automatically running every your computer starting up.

Ever you hear about gnokii?

gnokii is an open source project. gnokii provides tools and a user space driver for use with mobile phones under Linux, various unices and Win32. With gnokii you can do such things as make data calls, update your address book, change calendar entires, send and receive SMS messages and load ring tones depending on the phone you have.

If you need a more information, please feel free to go to gnokii official site on http://www.gnokii.org/
If you need gnokii Wiki, please go to http://wiki.gnokii.org/
If you want to join to the mailing list, please go to gnokii-users@nongnu.org or http://lists.nongnu.org/mailman/listinfo/gnokii-users

Me, my friends Pawel Kot, Borbely Zoltan, and others gnokii users would like to help you on using gnokii for your mobile phones.

Thursday, July 27, 2006

How to interact Apache-Tomcat with Apache-HTTP server

As a default, we can accessing Apache-Tomcat web server on port 8080. But, in a production server, Apache-Tomcat must be accessed on port 80.

Below are step-by-step to do that.

(1) Download mod_jk2.so from http://apache.cbn.net.id/tomcat/tomcat-connectors/jk2/binaries/ unzip and put file mod_jk2.so to the {APACHE_DIR}\modules directory

(2) Add this line below to the {APACHE_DIR}\conf\httpd.conf file

LoadModule jk2_module modules/mod_jk2.so

(3) Create a file workers2.properties and save to {APACHE_DIR}\conf

Below are the content file of workers2.properties :

[shm]
info=Scoreboard. Requried for reconfiguration and status with multiprocess servers.
file=anon

# Defines a load balancer named lb. Use even if you only have one machine.
[lb:lb]

# Example socket channel, override port and host.
[channel.socket:localhost:8009]
port=8009
host=127.0.0.1

# define the worker
[ajp13:localhost:8009]
channel=channel.socket:localhost:8009
group=lb

# Map the Tomcat examples webapp to the Web server uri space
[uri:/examples/*]
group=lb

# Map the AR (Account Receivable Project) to the Web server uri space
[uri:/ar/*]
group=lb

[status:]
info=Status worker, displays runtime information

[uri:/jkstatus/*]
info=The Tomcat /jkstatus handler
group=status:


(4) Now, restart your Apache-Tomcat and Apache web server.

(5) Done.

Install Java Plugin to Browser

After installing JRE on linux of course we want our browser enable running java. Below are step-by-step on how to do that.

(1) Go to your browser plugins directory. For example, if you are using Netscape then type this command

cd /usr/lib/Netscape6/plugins

(2) Create a soft link to your libjavaplugin

ln -s /usr/java/j2re-1_4_2_09/plugin/i386/ns610-gcc32/libjavaplugin_oji.so .

(3) Restart your browser

(4) Change your browser preference

Choose Edit -> Preferences

(5) Enable Java checkbox

(6) Done

How to install JRE on Linux

It's easy to install JRE (Java Runtime Environment) on linux. Below are step-by-step on how to do that.

(1) Get a JRE installer from java.sun.com

(2) Change as a superuser with this command

su

(3) Go to the directory where JRE would be installed. For a sample

cd /usr/java

(4) Change the JRE installer mode so the installer can be execute by linux

chmod a+x jre-1_4_2_09_linux.bin

(5) Execute an installer

./jre-1_4_2_09_linux.bin

(6) Done.

Wednesday, July 26, 2006

How to make your ATX machine automatically shutting down on Linux

For some ATX machine, it may cannot automatically shutting down on Linux. How to fix this ?

(1) Find a file name rc.modules
(2) You can find this file by typing a command :

locate rc.modules

(3) Edit that file with this command :

vi rc.modules

(4) Find a row containing "/sbin/modprobe apm"
(5) If there is a comment "#", uncomment that or delete the "#" sign on that row
(6) Rebooting your machine to test an effect.

How to make your ATX machine automatically shutting down on windows XP

For some ATX machine, it may cannot automatically shutting down on WIndows XP. How to fix this ?

(1) Go to the Control Panel
(2) Go to the Power Options (on some Windows XP version it may Performance and Maintenance)
(3) Click on the ATM tab
(4) Enable Advanced Power Management Support checkbox.
(5) Shutting down your machine to test the effect.

Burning CD on Slackware 8.1 with cdrecord

In this article, i'll show you how to burning CD on Slackware Linux version 8.1

(1) If you want to burning a CD data, for a first time you must convert your data to ISO format. For example, if you want burning all *.mp3 files then you must create your ISO with this command :

mkisofs -J -l -r -o song.iso *.mp3

And then you can burning your ISO files with this command :

cdrecord -v -multi -data speed=24 dev=0,0,0 song.iso

For your attention, this command used if you want to burn a data on a fresh blank CD. The option -multi used in order to make your CD multi session.

(2) To continuing your burning on the same CD with multi session, you need to find where is the start location of your next burning. You can do this by typing this command :

cdrecord -msinfo dev=0,0,0

To burn a next data, it's same as the first step. Create a second ISO file, for example :

mkisofs -J -l -r -o doc.iso -M /dev/cdrw -c 0,49354 *.doc

And then to burning your ISO use :

cdrecord -v -multi -data speed=24 dev=0,0,0 doc.iso

It's easy. Isn't it ? It may all step above useful for the other Slackware or Linux version.

Tuesday, July 25, 2006

Oracle Standard Exceptions

Below are Oracle Standard Exceptions.

Exception Name : DUP_VAL_ON_INDEX
Oracle Error : ORA-00001
Explanation : You tried to execute an INSERT or UPDATE
statement that has created a duplicate value in a field
restricted by a unique index.

Exception Name : TIMEOUT_ON_RESOURCE
Oracle Error : ORA-00051
Explanation : You were waiting for a resource and you
timed out.

Exception Name : TRANSACTION_BACKED_OUT
Oracle Error : ORA-00061
Explanation : The remote portion of a transaction has
rolled back.

Exception Name : INVALID_CURSOR
Oracle Error : ORA-01001
Explanation : You tried to reference a cursor that does
not yet exist. This may have happened because you've
executed a FETCH cursor or CLOSE cursor before
OPENing the cursor.

Exception Name : NOT_LOGGED_ON
Oracle Error : ORA-01012
Explanation : You tried to execute a call to Oracle before
logging in.

Exception Name : LOGIN_DENIED
Oracle Error : ORA-01017
Explanation : You tried to log into Oracle with an invalid
username/password combination.

Exception Name : NO_DATA_FOUND
Oracle Error : ORA-01403
Explanation : You tried one of the following:

1. You executed a SELECT INTO statement and no rows
were returned.
2. You referenced an uninitialized row in a table.
3. You read past the end of file with the UTL_FILE package.

Exception Name : TOO_MANY_ROWS
Oracle Error : ORA-01422
Explanation : You tried to execute a SELECT INTO
statement and more than one row was returned.

Exception Name : ZERO_DIVIDE
Oracle Error : ORA-01476
Explanation : You tried to divide a number by zero.

Exception Name : INVALID_NUMBER
Oracle Error : ORA-01722
Explanation : You tried to execute an SQL statement that
tried to convert a string to a number, but it was unsuccessful.

Exception Name : STORAGE_ERROR
Oracle Error : ORA-06500
Explanation : You ran out of memory or memory was
corrupted.

Exception Name : PROGRAM_ERROR
Oracle Error : ORA-06501
Explanation : This is a generic "Contact Oracle support"
message because an internal problem was encountered.

Exception Name : VALUE_ERROR
Oracle Error : ORA-06502
Explanation : You tried to perform an operation and there
was a error on a conversion, truncation, or invalid
constraining of numeric or character data.

Exception Name : CURSOR_ALREADY_OPEN
Oracle Error : ORA-06511
Explanation : You tried to open a cursor that is already open.

Connecting Java Server Pages (JSP) with MySQL

If we learn a new software technology, of course we want to know how the software connected to the database. In this article, i'll explain how Java Server Pages (JSP) connected with MySQL.

For a note :

(1) If you installed Apache-Tomcat Web Server, the default directory for JSP are in "/webapps/examples/jsp". It can be different for any version of Apache-Tomcat depending of your Apache-Tomcat version.


(2) If you want to use your own .class, make a new .class and put on "/webapps/examples/WEB-INF/classes/your_class_name". If that directory doesn't exist please fill free to create a new one. Only your .class file is needed.

To connect with MySQL, you need mysql-connector-java. You can download it from MySQL official site. Copy "mysql-connector-java-3.0.8-stable-bin.jar" to "$JAVA_HOME/jre/lib/ext" and then restart your Apache-Tomcat web server.

Below is an example script how JSP get a data from MySQL database.

<%@ page import="java.sql.*" %>
<%
String connectionURL = "jdbc:mysql://localhost:3306/pudak2?user=;password=";
Connection connection = null;
Statement statement = null;
ResultSet rs = null;
%>
<html>
<body>
<%
Class.forName("com.mysql.jdbc.Driver").newInstance();
connection = DriverManager.getConnection(connectionURL,"","");
statement = connection.createStatement();
rs = statement.executeQuery("SELECT * FROM t_admin");
while (rs.next()) {
out.println (rs.getString("adm_code")+"<br/>");
}
rs.close();
%>
</body>
</html>


That's all. In the next article, i'll explain how to interact Apache-Tomcat with Apache-HTTP server, so Apache-Tomcat can use port 80. Happy learning Java Server Pages.

Step by Step Rebuilding Kernel on Ubuntu Breezy 5.10

Sometimes, we need to configure our own kernel to fulfill our need. Below are step by step on rebuilding kernel on Ubuntu Breezy 5.10

(1) Make sure you have build-essential, bin86, and kernel-package package installed on your system. If no, please install with this command

apt-get install build-essential bin86 kernel-package

(2) Make sure you have development package libncurses-dev installed on your system. If no, please install with this command

apt-get install libncurses-dev

(3) Make sure you have package linux-tree installed on your system. If no, please install with this command

apt-get install linux-tree-2.6.8.1

(4) Go to the /usr/src directory

cd /usr/src

(5) Extract your linux source

tar jxf linux-source-2.6.8.1.tar.bz2

(6) Create soft link

ln -s linux-source-2.6.8.1 linux

(7) Go to /usr/src/linux directory

cd /usr/src/linux

(8) Copy config file

cp /boot/config-2.6.8.1-3-688 .config

(9) Make oldconfig with this command

make oldconfig

(10) Make kpkg clean with this command

make-kpkg clean

(11) Edit Makefile and suit with your needs

vi Makefile

(12) Make package installer with this command

make-kpkg --initrd --stem linux-revision=n3120 kernel_image

(13) Up one level directory with this command

cd ..

(14) Install a new package installer with this command

dpkg -i linux-image-2.6.8.1_n3120_i386.deb

(15) Ok. Now everything done. Reboot your machine and use your new configured kernel

Monday, July 24, 2006

The Meaning of > /dev/null 2>&1

Sometimes, if we work under Linux world, we would find the "> /dev/null 2>&1" syntax. What it's mean?

  • The first part, "> /dev/null" means send standard output to the "bit bucket" or in other words, throw it away.
  • The second part, "2>&1" means "redirect standard error (2) to the same place as standard output (1)

That's all. Happy using Linux.

The Important of Project Document

Maybe for some developer's who got a new job or a new position in a new place, not only developing a new application but he/she must and have a duty to maintain other application that had been running for many times and may be many years.

It's important that the Project Leader must forcing the developer to make a well documented project document.

As this happen to me. I have to shoot directly to the database from a thousand member data from the other database type - in this case .DBF - so, i have to converti it to the csv and then load to the database. But, what is the important? I have to know the database design firstly. What happen if there are no documented. I have to trace and re-engineered a database so i can tracert the logic or relationship of database.

It's something difficult. So, keep your project well documented.

How to DROP COLUMN On Oracle TABLE

Sometimes we need to DROP COLUMN from the database table. But, how it works on Oracle?

First, you must set the column as the unused column.
ALTER TABLE TABLE_NAME SET UNUSED COLUMN COLUMN_NAME;

Second, you must drop the unused column.
ALTER TABLE TABLE_NAME DROP UNUSED COLUMNS;

Note :
TABLE_NAME is your database table name.
COLUMN_NAME is your database column on the table.

Is TOAD Incompatible with Oracle 10g ?

As a software developer, of course there are many tools that i need to try and choose what are the best tools for developing the application.

On my experience, i have found that TOAD and PL/SQL Developer is a good tools for managing Oracle databases. But, since Oracle 10g released there is a strange between TOAD and Oracle. Especially if we DROP the Oracle TABLE from TOAD. It would evoke the Oracle 10g to raise the fake TABLE like BIN$9+bny8IM+WbgMBCsHAEm/A==$0 who's mean that this is DDL/DML objects in Recycle Bin.

At the first time, i think this is the incompatibility between TOAD and Oracle 10g. But, next i found that the recycle bin is the new featured on Oracle 10g. So, TOAD still work with Oracle 10g without any incompatibility.

Friday, July 21, 2006

mysql_connect(): Client does not support authentication protocol

When you are upgrading MySQL from MySQL 3 or MySQL 4.0 to MySQL 4.1, you may find this error message

mysql_connect(): Client does not support authentication protocol

So, what should we do?

If, you have a lot of application then you may add the following statement to the [mysqld] section on MySQL configuration file (my.cnf)

old-passwords=1

Then, all of your application will be working like your MySQL prior plus you can maximize the new features on MySQL 4.1.

A Little Bit Lack of Java

The first my interesting of Java is the ability to hide the scripting code from the .java to .class. So, I can put or give the source without any worry if the others can look at my code.

I know in the world of open source is to open the source we have so anyone can learn and give the action if there is a lack on our code. But, sometimes i want to hide the code.

Now, there is a tools to decompile the .class to .java. So, its a little bit to reduce the strength of Java and my interest. I don't know if Sun Microsystem do a new technology or improvement to compile the source, so no one can look at the original source code.

The Lack of Oracle

As of my own experience, i can told that i found some lack of Oracle. Previously i am a MySQL database user.

Here is a lack of Oracle :
1. There is no LIMIT feature like a MySQL databases.
2. If you want to change a field in a database like insert a new field between 2 field, you can not do it. It always added on the last field.

For the first lack I do this statement :

In MySQL :
----------
"SELECT DIVISION_CODE, DIVISION_NAME, LKP_NAME FROM T_DIVISION T1, TSYS_LKP T2 WHERE T1.IS_ACTIVE = T2.LKP_CODE AND LKP_TYPE = 'IS_ACTIVE_TYPE' ORDER BY 1 ASC LIMIT 0, 30"

In Oracle :
-----------
"SELECT DIVISION_CODE, DIVISION_NAME, LKP_NAME, NO_RECORD FROM (SELECT DIVISION_CODE, DIVISION_NAME, T2.LKP_NAME, ROW_NUMBER() OVER (ORDER BY DIVISION_CODE ASC) NO_RECORD FROM T_DIVISION T1, TSYS_LKP T2 WHERE T1.IS_ACTIVE = T2.LKP_CODE AND LKP_TYPE = 'IS_ACTIVE_TYPE' ) WHERE NO_RECORD BETWEEN 1 AND 30 ORDER BY 1 ASC"

For the second, you must drop and recreate table with a new structure.

Changing BIOS Date via Linux

Sometimes if we change the date on linux with date or time function, whenever the computer starting up again, the date setting is back to the BIOS time. It's mean that the date or time function only affect to the linux operating system but not to the BIOS.

So, you can do this :

[root@ppbj root]#hwclock --set --date="2006-07-21 10:15:00"
[root@ppbj root]#hwclock --hctosys


Restart your computer. And then you'll find your BIOS time changed with your new setting.

Script for Shutting Down Oracle10g

Below is the script to make you easier to shutting down your Oracle10g database on Linux. Create a file, for example : dbstop.sh and then fill the content of file like this :

#!/bin/sh
#(c) 2005 Asep Andria
#
lsnrctl stop
sleep 2
sqlplus "/ as sysdba" << EOF
shutdown immediate

exit
EOF

emctl stop dbconsole

#--- end of script ---#

Script for Starting Up Oracle10g

Below is the script to make you easier to starting up your Oracle10g database on Linux. Create a file, for example : dbstart.sh and then fill the content of file like this :

#!/bin/sh
#(c) 2005 Asep Andria
#
lsnrctl start
sleep 2
sqlplus "/ as sysdba" << EOF
startup

exit
EOF

sleep 2

emctl start dbconsole
sleep 2

#--- end of script ---#

MySQL Error Handling

Sometimes, if we work with MySQL database, when there are an error (like cannot dumping database or table corrupt), MySQL would echoing the error code, so the Database Administrator can recognize the error and recover the database.

But, what should we do? What kind of error is that?

Ok. Just go to the MySQL bin directory and then type perror ERROR_CODE. For example, if your MySQL echoing error 127 then you must type perror 127. MySQL would give you an explanation what kind of error of it.

If there are a table corrupt, you can use myisamchk or mysqlcheck syntax to analyze, check, repair or optimize the database.

What is the different between myisamchk and mysqlcheck ?

If you use myisamchk, your MySQL database must be shutting down.
If you use mysqlcheck, you can repair the database while your MySQL database is running up.

Example syntax :

This is to analyze the its database with root user :

[root@ppbj root]# mysqlcheck -a its -u root -p
Enter password:

And then the terminal would echoing the status of MySQL tables like below :

its.adminweb OK
its.t_activity OK
its.t_activity_image OK
its.t_branch OK
its.t_category OK
its.t_contact OK
its.t_division OK
its.t_download OK
its.t_event OK
its.t_group_access OK
its.t_menu OK
its.t_menu_level OK
its.t_news OK
its.t_news_review Table is already up to date
its.t_polling OK
its.t_polling_log OK
its.t_polling_option OK
its.t_procedure Table is already up to date
its.t_profile OK
its.t_profile_group OK
its.t_retailnews OK
its.t_retailnews_image Table is already up to date
its.trel_profile_group OK
its.tsys_lkp OK
its.tsys_sql Table is already up to date
its.tsys_string OK
its.tsys_user OK
its.tsys_var OK

Another mysqlcheck option is :
-a, to analyze the database
-c, to check the database
-r, to repair the database
-o, to optimize the database