Pages

Tuesday 17 September 2013

ORACLE SELECT RECORD BETWEEN No1. TO No2.

In some cases we have to select the records from the database table between some specific value. Like I want to select record 1 TO 10 at first time 11 TO 20 at second time like this.

For this i have a solution with just a single query:

------------------------------------------------------------------------------------------------------------
SELECT * 
FROM (SELECT ALIAS1.*, ROW_NUMBER() OVER(ORDER BY column_name) AS MYROW FROM table_name ALIAS1 WHERE ALIAS1.column_name = where_clause) 
WHERE (MYROW BETWEEN 1 AND 10);
---------------------------------------------------------------------------------------------------------------------------------

EXPLANATION:-
In this Query Inner select query will select all the record from given table_name that satisfy the Inner WHERE clause and provide row number to each record and make it as table alias MYROW. Now outer WHERE clause will select 1 to 10 record from that record and display it as final output.


IF YOU HAVE BETTER WAY TO DO THIS THEN PLEASE PROVIDE IT AS COMMENT IT WILL VERY HELPFUL.

Friday 6 September 2013

How To Create JAR File Step By Step

The JAR file format is a compressed format used primarily to distribute Java applications and libraries. It is built on the ZIP file format, and functions in a similar way; many files are compressed and packaged together in a single file, making it easy to distribute the files over a network. If you need to package a Java application or library, you can create a JAR file using the Java Development Kit (JDK) and your computer's command prompt.

Method One: Windows

1. Prepare your files. Place all the files you want to include in the JAR file inside a single folder. They will need to be referenced through a single command line, so specifying separate paths is not feasible.
2. Open the command prompt. This can be done by clicking on Start and then Run. Type "cmd" into the text box and click the "OK" button.

3. Navigate to the folder where you stored your files. By default, the command prompt will read "C:\>."
  • To navigate deeper into the hard drive, use the "change directory" command by typing "cd."
  • For example, if your files are stored at "C:\myfiles," then you should type "cd \myfiles."
4. Set the path to the directory of the JDK bin. You will need to run the jar.exe utility to create a JAR file, and that file is located in the bin directory.
  • Use the "path" command to specify the JDK bin directory. For example, if you installed JDK to the default location, you would type: "path c:\Program Files\Java\jdk1.5.0_09\bin"
  • If you aren't sure of the exact directory, navigate to it in Windows Explorer and take note of the directory's full path.
5. Create the JAR file. The format of the command line for creating the JAR file looks like this: "jar cf 'jar-file'.jar input-file(s)."
  • The "jar" portion refers to the jar.exe program, which compiles the JAR file.
  • The "c" option specifies that you want to create a JAR file
  • The "f" option means that you want to specify the filename.
  • The "jar-file" portion is where you should type the name that you want the file to have.
  • "Input-file(s)" is a space-separated list of all the files to be included in the JAR file.
  • For example, you might type "jar cf myjar manifest.txt myclass.class." This would create a JAR file with the filename "myjar.jar" which would include the files "manifest.txt" and "myclass.class."
  • If you add directories to the JAR file, the jar.exe utility will automatically add their contents.

Method Two: Mac

  1. Prepare your files. Put all the files you want to include in the JAR file inside a single folder.
    • Open a Terminal command prompt, and set it to the target directory where your JAR files are located.
  2. Compile the .java class. For example, compile HelloWorld.java with:
    • javac HelloWorld.java
    • This will produce a .class file needed for the JAR file.
  3. Create a manifest file. Save it using the extension .txt using the text editor and input the following:
    • Main-Class: HelloWorld (or whatever your file's name is)
  4. Create the JAR file using this code:
    • jar cfm HelloWorld.jar Manifest.txt HelloWorld.class
  5. Run the file:jar