Basic differences between Oracle and SQL Server

ORACLE
  • Oracle provides password complexity enforcement rule.
  • Connect with one Schema and can work with other schema.
  • Oracle implemented the row versioning on the DB block level.
  • Oracle metadata is managed in the same manner as table data.So during data querying most of online DDL statements on the table can be performed simultaneously.
  • Starting from Oracle 9i the configuration of ROLLBACK SEGMENTS is automatic.
  • Oracle is well rich with Index Options.
  • Oracle provides Automatic Storage Management (ASM), which assists with RAC/Grid based cluster deployment.
  • Oracle provides proprietary cluster file system on Linux and Windows platforms that helps in avoiding the use of raw devices.
  • Oracle provides Materialized Views for performance improvements of Stored Data with multiple Tables.
  • Oracle has more recovery options for corrupted database, redo log or datafile than MSSQL.
MS SQL
Microsoft implemented row level lock based on each single row.
SQL Server
  • all DDL operations that are currently running on tables belong to database "Snapshot Isolation". "Snapshot Isolation" queries are prohibited.
  • SQL requires a complex setup of ROLLBACK Segments and Transaction Level use on it.
  • SQL has just BTREE Index while compare to Oracle.
  • SQL has limitations using Materialized Views.

What is the difference between DBMS and RDBMS?

DBMS :  Data Base Management System
1)A DBMS has to be persistent (it should be accessible when
the program created the data donot exist or even the
application that created the data restarted).
2) DBMS has to provide some uniform methods independent of a
specific application for accessing the information that is
stored.
3)DBMS does not impose any constraints or security with
regard to data manipulation. It is user or the programmer
responsibility to ensure the ACID PROPERTY of the database
4)In DBMS Normalization process will not be present

RDBMS:  Relational Data Base Management System

1)RDBMS is based on relational model, in which data is
represented in the form of relations, with enforced
relationships between the tables.
2)RDBMS defines the integrity constraint for the purpose of
holding ACID PROPERTY.
3)In RDBMS, normalization process will be present to check
the database table cosistency
4)RDBMS helps in recovery of the database in case of loss of
database due to system failure or any other reason

A DBMS has to be persistent, that is it should be accessible when theprogram created the data ceases to exist or even the application thatcreated the data restarted. A DBMS also has to provide some uniformmethods independent of a specific application for accessing theinformation that is stored.  
 Many DBA's think that RDBMS is a Client Server Database system but thats not the case with RDBMS.

5 Common Errors in Setting Java Heap Size

Two JVM options are often used to tune JVM heap size: -Xmx for maximum heap size, and -Xms for initial heap size. Here are some common mistakes I have seen when using them:

1. Only setting -Xms JVM option and its value is greater than the default maximum heap size, which is 64m. The default minimum heap size seems to be 0. For example,
      java -Xms128m BigApp
      Error occurred during initialization of VM
      Incompatible initial and maximum heap sizes specified
      The correct command should be java -Xms128m -Xmx128m BigApp. It’s a good idea to set the minimum and maximum heap size to the same value. In any case, don’t let the minimum heap size exceed the maximum heap size.
Heap size is larger than your computer’s physical memory. For example,
      java -Xmx2g BigApp
      Error occurred during initialization of VM
      Could not reserve enough space for object heap
      Could not create the Java virtual machine.
      The fix is to make it lower than the physical memory: java -Xmx1g BigApp
    2.Incorrectly use mb as the unit, where m or M should be used instead.
      java -Xms256mb -Xmx256mb BigApp
      Invalid initial heap size: -Xms256mb
      Could not create the Java virtual machine.
    3 The heap size is larger than JVM thinks you would ever need. For example,
      java -Xmx256g BigApp
      Invalid maximum heap size: -Xmx256g
      The specified size exceeds the maximum representable size.
      Could not create the Java virtual machine.
      The fix is to lower it to a reasonable value: java -Xmx256m BigApp
    4.The value is not expressed in whole number. For example,
      java -Xmx0.9g BigApp
      Invalid maximum heap size: -Xmx0.9g
      Could not create the Java virtual machine.
      The correct command should be java -Xmx928m BigApp
NOTE:
How to set java heap size in Tomcat?
Stop Tomcat server, set environment variable CATALINA_OPTS, and then restart Tomcat. Look at the file tomcat-install/bin/catalina.sh or catalina.bat for how this variable is used. For example,
set CATALINA_OPTS=”-Xms512m -Xmx512m”  (Windows)
export CATALINA_OPTS=”-Xms512m -Xmx512m”  (ksh/bash)
setenv CATALINA_OPTS “-Xms512m -Xmx512m”  (tcsh/csh)
In catalina.bat or catallina.sh, you may have noticed CATALINA_OPTS, JAVA_OPTS, or both can be used to specify Tomcat JVM options. What is the difference between CATALINA_OPTS and JAVA_OPTS? The name CATALINA_OPTS is specific for Tomcat servlet container, whereas JAVA_OPTS may be used by other java applications (e.g., JBoss). Since environment variables are shared by all applications, we don’t want Tomcat to inadvertently pick up the JVM options intended for other apps. I prefer to use CATALINA_OPTS.
How to set java heap size in JBoss?
Stop JBoss server, edit $JBOSS_HOME/bin/run.conf, and then restart JBoss server. You can change the line with JAVA_OPTS to something like:
JAVA_OPTS=”-server -Xms128m -Xmx128m”
How to set java heap size in Eclipse?
You have 2 options:
1. Edit eclipse-home/eclipse.ini to be something like the following and restart Eclipse.
-vmargs
-Xms64m
-Xmx256m
2. Or, you can just run eclipse command with additional options at the very end. Anything after -vmargs will be treated as JVM options and passed directly to the JVM. JVM options specified in the command line this way will always override those in eclipse.ini. For example,
eclipse -vmargs -Xms64m -Xmx256m
How to set java heap size in NetBeans?
Exit NetBeans, edit the file netbeans-install/etc/netbeans.conf. For example,
netbeans_default_options=”-J-Xms512m -J-Xmx512m -J-XX:PermSize=32m -J-XX:MaxPermSize=128m -J-Xverify:none
How to set java heap size in Apache Ant?
Set environment variable ANT_OPTS. Look at the file $ANT_HOME/bin/ant or %ANT_HOME%\bin\ant.bat, for how this variable is used by Ant runtime.
set ANT_OPTS=”-Xms512m -Xmx512m”  (Windows)
export ANT_OPTS=”-Xms512m -Xmx512m”  (ksh/bash)
setenv ANT_OPTS “-Xms512m -Xmx512m”  (tcsh/csh)
How to set java heap size in jEdit?
jEdit is a java application, and basically you need to set minimum/maximum heap size JVM options when you run java command. jEdit by default runs with a default maximum heap size 64m. When you work on large files, you are likely to get these errors:
java.lang.OutOfMemoryError: Java heap space
at java.lang.String.concat(String.java:2001)
at org.gjt.sp.jedit.buffer.UndoManager.contentInserted(UndoManager.java:160)
at org.gjt.sp.jedit.Buffer.insert(Buffer.java:1139)
at org.gjt.sp.jedit.textarea.JEditTextArea.setSelectedText(JEditTextArea.java:2052)
at org.gjt.sp.jedit.textarea.JEditTextArea.setSelectedText(JEditTextArea.java:2028)
at org.gjt.sp.jedit.Registers.paste(Registers.java:263)
How to fix it? If you click a desktop icon, or Start menu item to start jEdit: right-click the icon or menu item, view its property, and you can see its target is something like:
C:\jdk6\bin\javaw.exe -jar “C:\jedit\jedit.jar”
You can change that line to:
C:\jdk6\bin\javaw.exe -Xmx128m -Xms128m -jar “C:\jedit\jedit.jar”
If you run a script to start jEdit: just add these JVM options to the java line inside the script file:
java -Xmx128m -Xms128m -jar jedit.jar
If you start jEdit by running java command: just add these JVM options to your java command:
java -Xmx128m -Xms128m -jar jedit.jar
Note that when you run java with -jar option, anything after -jar jar-file will be treated as application arguments. So you should always put JVM options before -jar. Otherwise, you will get error:
C:\jedit>java -jar jedit.jar -Xmx128m
Unknown option: -Xmx128m
Usage: jedit [] []
How to set java heap size in JavaEE SDK/J2EE SDK/Glassfish/Sun Java System Application Server?
Stop the application server, edit
$GLASSFISH_HOME/domains/domain1/config/domain.xml, search for XML element name java-config and jvm-options. For example,

-Xmx512m
-XX:NewRatio=2
-XX:MaxPermSize=128m

You can also change these settings in the web-based admin console, typically at http://localhost:4848/, or https://localhost:4848/. Go to Application Server near the top of the left panel, and then on the right panel, click JVM Settings -> JVM Options, and you will see a list of existing JVM options. You can add new ones and modify existing ones there.
Yet another option is to use its Command Line Interface (CLI) tool command, such as:
./asadmin help create-jvm-options
./asadmin help delete-jvm-options
They may be a bit hard to use manually, but are well suited for automated scripts.

JavaScript: Dynamically Add/Remove rows in HTML table

This article shows you how to add rows to a HTML table dynamically, using DHTML and JavaScript - without requiring a round trip to the web server. I used this technique in a project to build a data entry grid, where the users wanted the flexibility to add or remove rows easily before doing a final submit/save. 
Source Code:

<HTML>
<HEAD>
     <TITLE> Dynamically Add/Remove rows in HTML table TITLE>
     <SCRIPT language="javascript">
          FUNCTION addRow(tableID) {
 
               VAR table = document.getElementById(tableID);
 
               VAR rowCount = table.rows.length;
               VAR row = table.insertRow(rowCount);
 
               VAR cell1 = row.insertCell(0);
               VAR element1 = document.createElement("input");
               element1.type = "checkbox";
               cell1.appendChild(element1);
 
               VAR cell2 = row.insertCell(1);
               cell2.innerHTML = rowCount + 1;
 
               VAR cell3 = row.insertCell(2);
               VAR element2 = document.createElement("input");
               element2.type = "text";
               cell3.appendChild(element2);
 
          }
 
          FUNCTION deleteRow(tableID) {
               TRY {
               VAR table = document.getElementById(tableID);
               VAR rowCount = table.rows.length;
 
               FOR(VAR i=0; i<rowCount; i++) {
                    VAR row = table.rows[i];
                    VAR chkbox = row.cells[0].childNodes[0];
                    IF(NULL != chkbox && TRUE == chkbox.checked) {
                         table.deleteRow(i);
                         rowCount--;
                         i--;
                    }
 
               }
               }CATCH(e) {
                    ALERT(e);
               }
          }
 
     SCRIPT>
HEAD>
<BODY>
 
     <INPUT type="button" value="Add Row" onclick="addRow('dataTable')" />
 
     <INPUT type="button" value="Delete Row" onclick="deleteRow('dataTable')" />
 
     <TABLE id="dataTable" width="350px" border="1">
          <TR>
               <TD><INPUT type="checkbox" NAME="chk"/>TD>
               <TD> 1 TD>
               <TD> <INPUT type="text" /> TD>
          TR>
     TABLE>
 
BODY>
HTML>

How to Convert Exponential Form of a number to Decimal Form in java

In Java you will see that most of the value are displayed in Exponential form while using Doubles and Long.


Example:
In following we are multiplying 4.58 with 10000 and the result is printed.
Double a = 4.58d / 10000;
System.out.println( a.doubleValue());
 
a = 2.85d * 100000000;
System.out.println( a.doubleValue());
Result:
4.58E-4
 4.58E8
You can do this simply by using class java.math.BigDecimal. In following example we are using BigDecimal.valueOf() to convert the Double value to BigDecimal and than .toPlainString() to convert it into plain decimal string.

import java.math.BigDecimal;
Double a = 4.58d / 10000;
System.out.println(BigDecimal.valueOf(a).toPlainString());
 a = 4.58d * 100000000;
System.out.println(BigDecimal.valueOf(a).toPlainString());
Result:
0.000458 
458000000

How to get JVM heap size, used memory, total memory using Java Runtime

Java’s Runtime class provide lot of information about the resource details of Java Virtual Machine or JVM. The memory consumed by the JVM can be read by different methods in Runtime class.
Following is the small example of getting/reading JVM Heap Size, Total Memory and used memory using Java Runtime api.

public class Memoryusage{
 
    public static void main(String [] args) {
 
        int mb = 1024*1024;
 
        //Getting the runtime reference from system
        Runtime runtime = Runtime.getRuntime();
 
        System.out.println("Heap Space usage in MB");
 
        //Print used memory
        System.out.println("Used Memory:"
            + (runtime.totalMemory() - runtime.freeMemory()) / mb);
 
        //Print free memory
        System.out.println("Free Memory:"
            + runtime.freeMemory() / mb);
 
        //Print total available memory
        System.out.println("Total Memory:" + runtime.totalMemory() / mb);
 
        //Print Maximum available memory
        System.out.println("Max Memory:" + runtime.maxMemory() / mb);
    }

Increase heap size in Java to prevent java.lang.OutOfMemoryError

Java programs executes in JVM uses Heap of memory to manage the data. If your Java program requires a large amount of memory, it is possible that the virtual machine will begin to throw OutOfMemoryError instances when attempting to instantiate an object. The default heap size if 1 MB and can increase as much as 16 MB.

Setting/Increase JVM heap size

It is possible to increase heap size allocated by the Java Virtual Machine (JVM) by using command line options.
Following are few options available to change Heap Size.

1
2
3
-Xms<size>        set initial Java heap size
-Xmx<size>        set maximum Java heap size
-Xss<size>        set java thread stack size

What is Java Heap Space in Java virtual Machine JVM?

Java heap is the heap size allocated to JVM applications which takes care of the new objects being created. If the objects being created exceed the heap size, it will throw an error saying memoryOutof Bound
Java's default heap size limit is 128MB.
It is possible to increase heap size allocated by the Java Virtual Machine (JVM) by using command line options.
Following are few options available to change Heap Size.

-Xms        set initial Java heap size
-Xmx        set maximum Java heap size
-Xss        set java thread stack size