Tuesday, January 30, 2018

PuTTY: Server refused to start a shell/command

After you entered the IP address, username and password to connect to your server, you received the following error.

               

If you are trying to connect to a FTP server using a SSH client such as PuTTY or a Linux/Unix SSH client, this kind of error occurs because FTP Server does not accept direct SSH connections. You need to use a FTP/SFTP client such as FileZilla to connect to your server.

-----------------------------------------------------------------------------------------------------------------
Watch the blessing and loving online channel: SupremeMasterTV live




If you have ever asked yourself these questions, this is the book for you. What is the meaning of life? Why do people suffer? What is in control of my life? Why is life the way it is? How can I stop suffering and be happy? How can I have a successful life? How can I have a life I like to have? How can I be the person I like to be? How can I be wiser and smarter? How can I have good and harmonious relations with others? Why do people meditate to achieve enlightenment? What is the true meaning of spiritual practice? Why all beings are one? Read the book for free here.

Friday, January 26, 2018

[Solved] ORA-32039: recursive WITH clause must have column alias list


2018.01.26 11:09:24:584: 4 :Y: java.sql.SQLException: ORA-32039: recursive WITH clause must have column alias list

        at oracle.jdbc.driver.T4CTTIoer.processError(T4CTTIoer.java:450)
        at oracle.jdbc.driver.T4CTTIoer.processError(T4CTTIoer.java:399)
        at oracle.jdbc.driver.T4C8Oall.processError(T4C8Oall.java:1017)
        at oracle.jdbc.driver.T4CTTIfun.receive(T4CTTIfun.java:655)
        at oracle.jdbc.driver.T4CTTIfun.doRPC(T4CTTIfun.java:249)
        at oracle.jdbc.driver.T4C8Oall.doOALL(T4C8Oall.java:566)
        at oracle.jdbc.driver.T4CPreparedStatement.doOall8(T4CPreparedStatement.java:215)
        at oracle.jdbc.driver.T4CPreparedStatement.doOall8(T4CPreparedStatement.java:58)
        at oracle.jdbc.driver.T4CPreparedStatement.executeForDescribe(T4CPreparedStatement.java:776)
        at oracle.jdbc.driver.OracleStatement.executeMaybeDescribe(OracleStatement.java:897)
        at oracle.jdbc.driver.OracleStatement.doExecuteWithTimeout(OracleStatement.java:1034)
        at oracle.jdbc.driver.OraclePreparedStatement.executeInternal(OraclePreparedStatement.java:3820)
        at oracle.jdbc.driver.OraclePreparedStatement.executeQuery(OraclePreparedStatement.java:3867)
        at oracle.jdbc.driver.OraclePreparedStatementWrapper.executeQuery(OraclePreparedStatementWrapper.java:1502)

The above error is caused by name collision between a name in your With clause (Common Table Expression) and a table name in your database.

For example, you have a table named Employee in your database and you constructed a query like this.

WITH employee AS (
    select empName, empTitle, empID, dptName
    from employee, department
    where empDepID = depID
)
select empName, empTitle, dptName, sum(saleAmt)
from employee e, sales s
where e.empID = s.empID
group by empName, empTitle, dptName;

This query will throw an error like the above one because the employee in the With clause collides with the employee table in the database. Change the employee in the With clause to something else will fix the problem.

-----------------------------------------------------------------------------------------------------------------
Watch the blessing and loving online channel: SupremeMasterTV live




If you have ever asked yourself these questions, this is the book for you. What is the meaning of life? Why do people suffer? What is in control of my life? Why is life the way it is? How can I stop suffering and be happy? How can I have a successful life? How can I have a life I like to have? How can I be the person I like to be? How can I be wiser and smarter? How can I have good and harmonious relations with others? Why do people meditate to achieve enlightenment? What is the true meaning of spiritual practice? Why all beings are one? Read the book for free here.

Thursday, January 25, 2018

linux: Protect a file from being deleted, overwritten or replaced by accident

Sometimes, files are deleted or changed by accidents such as software update or a typo in a command. To protect a file from being altered by such an accident, it can be set to be immutable even a root user cannot delete or edit it.

The command to set the file immutable is below.

      chattr +i filename

Only a root user can execute this command. It changes the immutable attribute of a file. Use this command to view what attributes of a file are set.

      isattr filename

To unset the immutable attribute of a file:

      chattr -i filename

Reference:
1. chattr - linux man page
2. chattr

--------------------------------------------------------------------------------------------------------------

                        
If you have ever asked yourself these questions, this is the book for you. What is the meaning of life? Why do people suffer? What is in control of my life? Why is life the way it is? How can I stop suffering and be happy? How can I have a successful life? How can I have a life I like to have? How can I be the person I like to be? How can I be wiser and smarter? How can I have good and harmonious relations with others? Why do people meditate to achieve enlightenment? What is the true meaning of spiritual practice? Why all beings are one? Read the book free here.



Wednesday, January 24, 2018

linux: Turn off DNS to only use /etc/hosts file for host look up

On linux, each line of the /etc/hosts file contains an IP address and the domain names for this IP address separated by a space. For example, the line below have the domain names localhost, myserver, and deserver mapped to IP address 127.0.0.1.

      127.0.0.1      localhost myserver deserver

It provides an alternative way to get IP address from a domain name without DNS (Domain Name Service) look up.

To turn off DNS look up and only use the /etc/hosts file on  linux: Login as root user.

1. Modify the /etc/host.conf file.

This Resolver Configuration file specifies the order of the domain name to IP address look up.  For example, the line below tells that the host look up program should look at the /etc/hosts file first; if it does not find the result there, it should then use the DNS to get the IP address; if the result is still not found, it will use the old NIS (Network Information System).

       order hosts,bind,nis

 To only use the /etc/hosts file for host look up, modify the line above to make it look like this.

      order hosts

2. Modify the /etc/nsswitch.conf file. 

The Name Service Switch (NSS) configuration file, /etc/nsswitch.conf, is used to determine the sources from which to obtain name-service information in a range of categories, and in what order.

To only use the /etc/hosts file for host look up, find the line starts with "hosts: " and make it look like below.

      hosts:  files

--------------------------------------------------------------------------------------------------------------

                        
If you have ever asked yourself these questions, this is the book for you. What is the meaning of life? Why do people suffer? What is in control of my life? Why is life the way it is? How can I stop suffering and be happy? How can I have a successful life? How can I have a life I like to have? How can I be the person I like to be? How can I be wiser and smarter? How can I have good and harmonious relations with others? Why do people meditate to achieve enlightenment? What is the true meaning of spiritual practice? Why all beings are one? Read the book free here.


Wednesday, January 17, 2018

linux: Reset the time zone

If your time is off by exactly one hour or hours, it is possible that the time zone or DST(Daylight Saving Time) is not set correctly.

Time zone and DST information is stored in the /usr/share/zoninfo directory. To reset the time zone, firstly pick the right time zone you want to use from the list here or from the /usr/share/zoninfo directory on your machine.

To view the current time of the time zone:
      [root@MyServer ~]# zdump  EST5EDT
      EST5EDT  Wed Jan 17 13:35:19 2018 EST

To view the DST of the time zone:
      [root@CSdevtst ~]# zdump  -v EST5EDT | grep 2018
      EST5EDT  Sun Mar 11 06:59:59 2018 UTC = Sun Mar 11 01:59:59 2018 EST isdst=0 gmtoff=-18000
      EST5EDT  Sun Mar 11 07:00:00 2018 UTC = Sun Mar 11 03:00:00 2018 EDT isdst=1 gmtoff=-14400
      EST5EDT  Sun Nov  4 05:59:59 2018 UTC = Sun Nov  4 01:59:59 2018 EDT isdst=1 gmtoff=-14400
      EST5EDT  Sun Nov  4 06:00:00 2018 UTC = Sun Nov  4 01:00:00 2018 EST isdst=0 gmtoff=-18000

The local time zone is determined by a symbolic link from /etc/localtime to one of the files in the /usr/share/zoninfo directory or its subdirectory. The way to change the time zone is to reset this symbolic link.

      For example, the time zone is currently set to Central Time
      [root@MyServer ~]# ls -l /etc/localtime
      lrwxrwxrwx 1 root root 27 Jan 16 18:03 /etc/localtime -> /usr/share/zoneinfo/CST6CDT

      [root@MyServer ~]# date
      Tue Jan 16 18:29:45 CST 2018

      To change the time zone to Eastern Time
       [root@MyServer ~]# mv /etc/localtime /etc/localtime.old

       [root@MyServer ~]# ln -s /usr/share/zoneinfo/EST5EDT /etc/localtime

      [root@MyServer ~]# date
      Tue Jan 16 18:29:55 EST 2018

After you reset the time zone, synchronize your hardware clock.

      [root@MyServer ~]# hwclock --systohc

If the above method of resetting time zone does not work, you can add export TZ=<time zone> to your .bash_profile. For example

       export TZ=US/EASTERN
       or
       export TZ=EST5EDT

--------------------------------------------------------------------------------------------------------------

                        
If you have ever asked yourself these questions, this is the book for you. What is the meaning of life? Why do people suffer? What is in control of my life? Why is life the way it is? How can I stop suffering and be happy? How can I have a successful life? How can I have a life I like to have? How can I be the person I like to be? How can I be wiser and smarter? How can I have good and harmonious relations with others? Why do people meditate to achieve enlightenment? What is the true meaning of spiritual practice? Why all beings are one? Read the book free here.




linux: display, reset, and synchronize hardware clock and kernel / system clock

The hardware clock is backed by the battery and runs all the time even the machine is turned off. The hardware clock is also know as the BIOS clock, RTC (Real Time Clock) or CMOS. The kernel clock, also known as the system clock or software clock, is maintained by the operating system. The system clock is set at boot time according to the hardware clock.

A. Display Date and Time

1. Display the hardware clock date and time

      You may need to login as root

      [root@MyServer ~]# hwclock
      Wed Jan 17 10:11:07 2018  -0.507816 seconds

2. Display the system clock date and tiem

      [root@MyServer ~]# date
      Wed Jan 17 10:56:24 EST 2018

B Sync Hardware Clock and System Clock

      The date and time has a difference between the hardware clock and the system clock.
      [root@MyServer ~]# hwclock
      Wed Jan 17 10:56:00 2018  -0.750876 seconds

      [root@MyServer~]# date
      Wed Jan 17 10:56:24 EST 2018

1. Copy system clock date and time to hardware clock

      [root@MyServer~]# hwclock -w
      or
      [root@MyServer~]# hwclock --systohc

2. Copy hardware clock date and time to system clock

      [root@MyServer~]# hwclock -s
      or
      [root@MyServer~]# hwclock -hctosys

C. Set The Harware Clock Date and Time Manually

      [root@MyServer~]# hwclock --set --date "1/17/2018 10:56:24"
      or
      [root@MyServer~]# hwclock --set --date "Wed Jan 17 10:56:24 EST 2018"

      If you don't specify the time, it will be set to 12:00:00AM
      [root@MyServer~]# hwclock --set --date 1/17/2018

D. Adjust the Hardware Clock

      This add or subtract time from the hardware clock to account for systematic drift since last time the clock was set or adjusted. 
     [root@MyServer~]# hwclock --adjust

--------------------------------------------------------------------------------------------------------------

                        

If you have ever asked yourself these questions, this is the book for you. What is the meaning of life? Why do people suffer? What is in control of my life? Why is life the way it is? How can I stop suffering and be happy? How can I have a successful life? How can I have a life I like to have? How can I be the person I like to be? How can I be wiser and smarter? How can I have good and harmonious relations with others? Why do people meditate to achieve enlightenment? What is the true meaning of spiritual practice? Why all beings are one? Read the book free here.

Monday, January 8, 2018

Sort a JTable with fixed / frozen columns

We would assume that the main table and the frozen table use the same table model. In order to have the frozen table sorted as well when the main table is sorted, you can share the table sorter of the main table with the frozen table.

//Make the main table sortable by clicking the column header
mainTable.setAutoCreateRowSorter(true);

frozenTable.setRowSorter(mainTable.getRowSorter());

//After sorting, the same number of row in the table is selected
frozenTable.setUpdateSelectionOnSort(false);

//After sorting, the same number of row in the model is selected
mainTable.setUpdateSelectionOnSort(true);

--------------------------------------------------------------------------------------------------------------

                        
If you have ever asked yourself these questions, this is the book for you. What is the meaning of life? Why do people suffer? What is in control of my life? Why is life the way it is? How can I stop suffering and be happy? How can I have a successful life? How can I have a life I like to have? How can I be the person I like to be? How can I be wiser and smarter? How can I have good and harmonious relations with others? Why do people meditate to achieve enlightenment? What is the true meaning of spiritual practice? Why all beings are one? Read the book free here.