Skip to main content

Posts

Showing posts from December, 2015

Project or Build Version Numbers

In Software world, every project/product release has one version number associated with it to identify on which version of code base it has.

Usually every project/product release has its version as follows.

(Major).(Minor).(Maintenance/Enhancements).(Build Number)

Major - If the release has Major changes in Project/Product then we need to increment this number by 1
Minor -   If the release has Minor changes in Project/Product then we need to increment this number by 1
Maintenance - If the release has Bug fixes or Small Enhancements then we need to increase this number by 1.

Build Number :  Every time when we deliver build (latest code) to the QA to test, then we need to increase by 1.

Partial Builds: If only some of the modules in the project modified and if those modules only delivered to QA means, it is called as partial builds. And this will be noted as build number along with alphabets.


E.G of Build Numbers.

Current Version of Project is 4.0.0.0 (4 Major Releases)
If Minor Project…

Linux Useful Commands with examples

To know the IP address
-----------
hostname -i (ip addres)
hostname -s (short name)
hostname -d (domain name)
hostname -v (host name with domain name)


To know the port number and running processes
netstat -ano | findstr 80

If the file is huge in size and to see the file content we can use
less <file name>
e.g. less service.log

Searching  matching pattern in file
grep '<matching text>' <file name>
e.g. grep 'Exception' service.log

To grep the text from .gz files
gzgrep '<matching text>' <gz file name>
e.g. gzgrep 'Exception' service.log.gz

ps -eaf | grep java
ps aus | grep java

tail -f <file Name> (auto updated last few lines)
tail -100 logfile.log  (last 100 lines)

ls -a  (hidden files)
ls -lrt (Sort the files by time stamp)

kill -9 <Process ID>   (get Process ID using ps -eaf | grep <process name>)
e.g. kill -9 30102

ClassNotFoundException vs NoClassDefFoundError

Both ClassNotFoundException and NoClassDefFoundError errors will be occurred  when the required Class not present in the Class path.

ClassNotFoundException

ClassNotFoundException is an Exception got arized when trying load class using
forName() method in class Class.
findSystemClass method in class ClassLoader .
loadClass method in class ClassLoader.

e.g. Class.forName("oracle.jdbc.driver.OracleDriver")
if the OracleDriver class file is not present in the Class path, then we will end up with this ClassNotFounException

NoClassDefFoundError

NoClassDefFoundError is an Error thrown at Runtime, when the Class is present during the compile time and not present during Runtime of the Code, then we will end up with this NoClassDefFoundError.

1. When required Class is not available at Runtime available only in compile time.
2.Since NoClassDefFoundError error is an Subclass of LinkageError, it will occur when one of the     Dependent of the jar not present in class path.
3. When the Static initia…

Content Extracting From 'CLOB' type Columns in SQL Querries

Extracting XML node value from CLOB  column in data base.

Syntax

ExtractValue(xml_fragment, xpath_expression)

Query Syntax

Select Extractvalue(XMLtype('<column name>'),'<XML node path>')
From <table list>
Where <conditions>

Example

Select Extractvalue(Xmltype(emp_xml), '/employees/empployee/emp_number')
From employee 
where  Status='A';

Updating a XML node value from CLOB  column in data base.

Syntax


UpdateXML(xml_target, xpath_expr, new_xml)

Query Syntax

Update table_name Set column_name=Updatexml(Xmltype('<column name>'),'<XML node path>','<Replacing XMLvalue'>).getclobval
From <table list>
Where <conditions>;

Example

Initial value /employees/empployee/emp_name/text() = Bhargava

Update employe Set emp_name = Updatexml(Xmltype(emp_xml), '/employees/empployee/emp_name/text()','Bhargava Surimenu')
where  emp_no=1207;

Comparator Vs Comarable

Comparable Interface

Comparable is an interface in java, which has only comparTo (Object Obj) method in it.
This is used to sort the user defined objects on specific member field.


When Comparable is preferred.

1. Having provision of modifying the User defined object to implement the Comparable interface. (Third party jar class objects doesn't have provision to modify).
2. Have a requirement to sort the User defined object by one Member field in their natural sorting order.
3. Comparable provides only one Sorting for an Object.

Our String and Wrapper Classes like Integer, Double, Long, BigDecimal etc. are override this compareTo method by implementing the Comparable Interface.


For example,
To sort the Bank Accounts  based on the amount it contains.

1. Create Account pojo with all the member fields including amount.
2. Implement the Account pojo with Comparable interface.
3. Override the compareTo(Object obj) method from Comparable interface. (Refer following code snippet)

Account…

"immutability" Nature of an Object

Immutability.

A Java object is considered to be immutable when its state (properties and contents) cannot change after it is created.

Use of immutable objects is widely accepted as a sound strategy for creating simple, reliable code. Immutable objects are particularly useful in concurrent applications. Since they cannot change state, they cannot be corrupted by thread interference or observed in an inconsistent state. java.lang.String and java.lang.Integer classes are the Examples of immutable

Immutable objects are simple to use test and construct.
Immutable objects are thread-safe by default.
Immutable objects are good Map keys and Set elements (Since state of these objects must not change while stored in a collection). This is the reason most of the times we prefer String objects as Key in many Map Collection objects.
Immutable objects do not require an implementation of clone.
Immutable objects allow hashCode to use lazy initialization, and to cache its return value.


To create a obje…