Wednesday, September 5, 2012

Oracle : Database link

For example


(DESCRIPTION=
(ADDRESS=(PROTOCOL=TCP)(HOST=localhost)(PORT=1521))
(CONNECT_DATA=(SID=mydb)))


1. Connect your oracle.
     > sqlplus /nolog
     > conn user/pass@mydb


2. Create db link :
     > Create database link monitordblink
connect to monitor identified by monitor123
using 'mydb';

the syntax is :

CREATE {PUBLIC} DATABASE LINK <database link name>
{CONNECT TO <oracle user id>
IDENTIFIED BY <remote oracle user's password> }
USING ' <dbstring> ';

3.  > Commit;

4. Check your db link :
    > SELECT * FROM all_db_links;


5. You can check table by using below command :
select <column list> from <table>@<dblink name>;
> select * from usertbl@monitordblink;


Source

Tuesday, September 4, 2012

Unix : Delete file or Folder


rm foo
delete the file named "foo"

rm a*
delete all files with names beginning with "a"

rm *.jpg
delete all files with names ending in ".jpg"

rm -R temp
delete the directory named "temp", and all of its contents

ClearCase

just for my reference only

> ct lsview
- see all ct view

> ct lsview *myname*
- search view contain "myname" string

> ct setview myname_view
- set view

> ct mkview yourname_view
- to create new view

Tuesday, July 24, 2012

Find File in unix

find /home/myname/ -name *myfile*

for current directory
find ./ -name *myfile*

grep "myname" listname.log

Monday, July 16, 2012

Java : Count lines in file


long lines = 1;
        try {
LineNumberReader  lnr = new LineNumberReader(new FileReader(new File("C:/testfile.txt")));
lnr.skip(Long.MAX_VALUE);
lines = lnr.getLineNumber();
} catch (FileNotFoundException e1) {
} catch (IOException e) {
}

The faster way to get total line in file...

Wednesday, June 6, 2012

UNIX : Create file using vi and cat

using vi or cat


vi command
> vi test.txt
       and press
      "ESC" button
       ":wq"

done.. type "ls" you will see the new file has been created.

cat command
> "cat > test1.txt"
     and then press "CTRL" + "D"

done.. see your directory..

Wednesday, May 16, 2012

UNIX : Find files that contain a string

Ref for me..

find . -exec grep -l "string to find" {} \;
change the "string to find" to find your string. Please include (")

also can do this..
find . -type f | xargs grep "String to find"

Java : Create File


Source code for create file. Example : text.txt, sample.dat, etc..



import java.io.File;
import java.io.IOException;

public class MakeFile {
public static void main(String[] args) {
File myFile = new File("myJava.java"); //change this filename
try {
myFile.createNewFile();
} catch (IOException e) {
System.out.println("Cannot created.");
}
}
public String createFile(String fileName) {
File myFile = new File(fileName);
try {
myFile.createNewFile();
return "0:OK";
} catch (IOException e) {
System.out.println(e.getMessage());
return "1:Not OK";
}
}
}

save as MakeFile.java

Wednesday, April 4, 2012

Change IP in LINUX Static

just my reference only.


      Make a backup of your /etc/network/interfaces file by typing the following in the console: 'cp /etc/network/interfaces /etc/network/interfaces.backup'

      Type 'vi /etc/network/interfaces' and press enter. Press 'i' to enter into insert (editing) mode.

      Scroll down until you find your network interface card in the file (usually named eth0 for an ethernet connection, or wlan0 or wifi0 for a wifi connection).

      Change 'iface eth0 inet dhcp' to 'iface eth0 inet static'

      Add the following lines, substituting the IP address numbers with your desired configuration:

          address 192.168.0.10
          netmask 255.255.255.0
          network 192.168.0.0
          broadcast 192.168.0.255
          gateway 192.168.0.1
          dns-nameservers 216.10.119.241


      Save and exit from the file by pressing Escape (to enter vi command mode), then ":wq" and Enter

      Type 'ifdown eth0' and press enter.

      Type 'ifup eth0' and press enter.


Source : http://www.wikihow.com/Assign-an-IP-Address-on-a-Linux-Computer

------

Configuring your Linux machine to run on a static IP is easy. Tools like system-config-network and netconfig provide you simple GUIs to do this.

For today, I’ll show you how to do this from the command line instead.

Navigate to /etc/sysconfig/network-scripts/

[root@baboo]# cd /etc/sysconfig/network-scripts/

Every network interface will have it’s own interface script file. eth0,eth1,eth2 and so on. Vi the ifcfg-eth0 interface script file for interface eth0. Replace the contents of the ifcfg-eth0 file with the parameters below.

[root@baboo]# vi ifcfg-eth0.

DEVICE=eth0
TYPE=Ethernet
ONBOOT=yes
BOOTPROTO=none
IPADDR=192.168.0.100
NETMASK=255.255.255.0
GATEWAY=192.168.0.1
HWADDR=00:0F:22:71:0A:53
USERCTL=no
USERCTL=no

If you want to switch back to DHCP, repeat the steps above and replace the contents of the ifcfg-eth0 file with the parameters below.

DEVICE=eth0
BOOTPROTO=dhcp
HWADDR=00:0F:20:71:0A:50
ONBOOT=yes
TYPE=Ethernet
DHCP_HOSTNAME=klmdrpdr01p.klm1.netcel360.com

Restart your interface to apply the changes.

[root@baboo]#ifdown eth0
[root@baboo]#ifup eth0

To update your dns server settings, modify the /etc/resolv.conf.

[root@baboo]# vi /etc/resolv.conf

Replace the contents of the resolv.conf file with the parameters below. The first parameter “search” is your search path followed the nameserver parameters which hold the IPs for your primary and secondary DNS servers.

search example.com
nameserver 192.168.0.5
nameserver 192.168.0.6

source : http://thedaneshproject.com/posts/how-to-configure-a-static-ip-in-linux/






Wednesday, March 21, 2012

.Net change string to date

Example


        Dim orderCreatedDateRaw As String = ""
        Dim tempTime As String = "201203220836"
        Dim dtDate As DateTime
        dtDate = DateTime.ParseExact(tempTime, "yyyyMMddHHmm", CultureInfo.CurrentCulture)
        orderCreatedDateRaw = dtDate.ToString("yyyy-MM-dd")

dont forget to import "System.Globalization"

org.apache.axis2.databinding.ADBException

This happen when client try to invoke the web service server... and then the error "org.apache.axis2.databinding.ADBException: Unexpected subelement ........." come out...

please check the parameter...

1st. see error remark.. "Unexpected subelement dataFeat"
2nd. find dataFeat parameter.
3rd. analysis your xml..

<listDatafeats>
<dataFeat></dataFeat>
<--- missing <dataFeat1> parameter -->
<dataFeat2></dataFeat2>
</listDatafeats>

so now you can ask the client side to change or add the parameter.

Sunday, January 8, 2012

Oracle : Date to Second Function

Below is sample for oracle function Date to second.


CREATE OR REPLACE FUNCTION TGATE_NI.DATE2TS (m_date_real IN DATE)
RETURN NUMBER IS
                m_unix_start_date_real                              DATE;
                m_days_difference                                     NUMBER;
                timeoutput                                                  NUMBER;
BEGIN
                m_unix_start_date_real := TO_DATE('19700101 0000', 'YYYYMMDD HH24MI');
               m_days_difference := (m_date_real - m_unix_start_date_real);
                timeoutput := (m_days_difference * 86400) - 28800;
                return timeoutput;
END;
/

Wednesday, January 4, 2012

MYSQL : Find duplicate

Just my reference..


select orderid, count(orderid) as totalorder
from order_list
group by orderid
order by totalorder desc;


will listed orderid and total duplicate.

JAVA : I/O Create file

Just a sample code for I/O...



import java.io.File;
import java.io.IOException;
public class CreateFile {
public static void main(String[] args)
{
try{
File file = new File("MyFile.txt"); if (file.createNewFile())
{
System.out.println("Sucess");
}
else
{
System.out.println("Already exist..");
}
}
catch (IOException e)
{
}
}
}

JAVA : OOP - Interface

Below example for Interface programming.


interface calc {
public int calc(int a, int b);
}
public class MyInterface implements calc{
public int calc(int a,int b )
{
return a + b; }
public static void main(String[] args)
{
MyInterface testInterface = new MyInterface();
int total;
total = testInterface.calc(1,7);
System.out.println("Total:" + total);
}
}


Interface only declare the method only. not include with the method body.

Java : OOP - Pass object to Method

Example for Pass object to Method.


class Kira {
void print(String str) {
System.out.println("In Kira :" + str);
}
}
public class test {
public static void main(String[] args) {
//System.out.println("testing 1 2 3....");
Kira kira = new Kira();
kira.print("Testing Kira");
}
}


Save file as test.java. Compile and run.....