Friday, April 20, 2018

Defference between the asperand @ and the exclamation point ! in sqlplus

The @ symbol runs a script in the current directory (or one specified with a full or relative path, or one that is found in your SQLPATH or ORACLE_PATH).

For example, you have an employeeList.sql file containing the following line.

select firstName, lastName from employee;

SQL> @employeeList
FIRSTNAME        LASTNAME
George                   Thomson
Richard                  Barton

The exclamation point tells sqlplus that we want to open a shell session and execute a command.

For example, you have the PrintWelcome.jar in your folder.

SQL> !java -jar PrintWelcome.jar
Welcome!!!

SQL> !pwd
/home/user/jarabon

file: printName.sh
#!/bin/bash
echo "My first name is George"
echo "My last name is OueLong"

SQL> !printName.sh
My first name is George
My last name is OueLong

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

                        
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.

Remove database locks that have been idle / inactive for at least 5 minutes

A. Oracle Database

//Find the all the row exclusive locks belong to dbuserID and have been inactive for more than
//5 minutes
SQL> select v1.sid, v1.serial#
           from v$session v1, v$locked_object v2
           where upper(v1.status)='INACTIVE' and v1.LAST_CALL_ET > 300 and                                                        upper(v2.ORACLE_USERNAME)='dbuserID' and v2.LOCKED_MODE=3
                      and v1.sid = v2.session_id;

//Remove the locks
SQL> ALTER SYSTEM KILL SESSION 'sid, serial#';


B. Postgresql

SQL> SELECT s.pid
           FROM pg_stat_activity s
           JOIN pg_locks p1 ON p1.pid = s.pid 
           WHERE (now() - s.query_start) > interval '5 minutes'
                    and upper(s.usename)='dbuserID' and upper(s.state) like 'IDLE%'
                    and p1.mode='RowExclusiveLock' and p1.granted is true;

SQL> select pg_terminate_backend(pid);

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

                        
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.

Friday, April 6, 2018

java: Will code following continue or break be executed? Will finally code / block be executed after break?

Below is a piece of code to test if code following continue or break be executed and finally code be executed after break.


public class Reward {

    protected int baseReward = 1000;

    protected int calculateReward() {
        return baseReward;
    }

    public Reward() {
        try {
            for (int i = 0; i < 100; i++) {
                if (i % 5 == 0) {
                    continue;
                } else if (i == 23) {
                    break;
                }
                int reward = calculateReward();
                System.out.println("The reward is " + i + "-" + reward);
            }
        } finally {
            System.out.println("Finished!!!");
        }
    }
   
    public static void main(String[] args){
        new Reward();
    }
}

Output:
The reward is 1-1000
The reward is 2-1000
The reward is 3-1000
The reward is 4-1000
The reward is 6-1000
The reward is 7-1000
The reward is 8-1000
The reward is 9-1000
The reward is 11-1000
The reward is 12-1000
The reward is 13-1000
The reward is 14-1000
The reward is 16-1000
The reward is 17-1000
The reward is 18-1000
The reward is 19-1000
The reward is 21-1000
The reward is 22-1000
Finished!!!

Conclusion: When the continue or break condition is satisfied, code in the loop following them will not be executed. The finally block will be executed when the break is executed and the program exits the loop.

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

                        
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.

Thursday, April 5, 2018

NetBeans: one or more project resources could not be found

When you open an existing java project from NetBeans, you get the following message.


[Thumbnail for referenceRUSAK.jpg]



To fix this, click the Close button to close the message. Right-click on the project and select Properties.


In the popped-up Project Properties window, select the Libraries under the Categories, and you will see a list of broken references on the Compile tab.



Select these broken references and click the Remove button to remove them.

Click the Add JAR/Folder button to add the jars needed or refer to this article to create and add the libraries you need for your project.

-----------------------------------------------------------------------------------------------------------------
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.


Tuesday, April 3, 2018

NetBeans: View, add, remove, replace jar(s) in an existing library

1. Right-click on your project in the Projects pane of NetBeans and select Properties.

2. In the Project Properties window, select Libraries under the Categories.

3. Choose the library you want to work on and click on the Edit button.

4. Select the jars you want to remove and click the Remove button.

5. Click the Add JAR/Folder... button to add a jar to the library.

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

                        
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.

NetBeans: Use / reference classes from external jars

If your code needs to use classes from other jars, get these jars and put them in folders at your discretion.

1. Click  on Tools in the top menu and select Liberaries


2. In the new pop-up Ant Library Manager window, click the New Library button at the bottom-left corner.


3. Enter the library name you want to use and click OK.


4. Click the Add JAR/Folder button to choose the jars you would like to add to the new library. Click the OK button.

5. In NetBeans, right-click on your project and select Properties.

6. In the Project Properties window, select Libraries under the Categories.



7. Click the Add Library button and select the library you want to add. Finally, click the OK button.

Of course, if your project only needs a few external jars, you can directly add them to your libraries by clicking the Add JAR/Folder button in the Project Properties window.

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

                        
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.







NetBeans: How to find all the @TODO items in your code

While developing the project for the initial main functions, you put reminders of the add-on things needed to put in later using comments like this.

//@TODO the changes to be made later

After you have finished the initial round of coding, you need to find all the TODO things to work on them. In NetBeans, you can find all of them by clicking the Window item in the top menu and select the Action Items.





You can right-click on an item in the Action Items pane and choose the Scope and Filter you want to apply to the list. If you select Show All from the Filter menu, it will display lines of code with compiling errors, quick fixes and style warnings in addition to the TODO things. You can also sort the entries in the Action Items by picking a method from the Sort By menu.

Double click on an item in the Action Items pane will take you to its location in your code.

Reference:





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

                        
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.