Saturday, 13 June 2020

PostGreSQL and PgAdmin Installation and Setup Guide

In this section, we are going to learn how to download, install and setup the process of PostGreSQL and PgAdmin.

Objectives

◈   Install PostGreSQL

◈   Install PgAdmin

◈   Restore Database

◈   Perform Example Query

PgAdmin

◈   Graphical Interface which is used to make queries.

◈  There are two versions, 3.x and 4.x

◈   PgAdmin 4 which is the latest and stable version, it opens in browser. Even if it opens in browser it doesn't require internet.

◈   PgAdmin 3 is no longer supported, means there will be no updates by the developer of PgAdmins. It opens as a program.

PostGreSQL

◈   PostGreSQL is the actual SQL engine that stores the data and from which we are quering from.

◈   Once we will install PgAdmin and PostGreSQL, then we will connect PostGreSQL Server to PgAdmin and then we can use that graphical interface to restore a database to that server.

Download PgAdmin

◈   First we will download PgAdmin from https://www.pgadmin.org/download/


◈   Once you are on the download page, select the appropriate operating system.

◈   Once the download is finished, click on the executable file and follow the GIF below.


Download PostGreSQL

◈   Now it is time to download PostGreSQL from https://www.pgadmin.org/download/.

◈   Once you are on the download page, select the approprate operating system.

◈   Once the download is finished, click on the executable file and follow the GIF below.

Monday, 1 June 2020

Key differences between java int and Integer

Hi, lets see one of the favourites question every interviewer asks, at the time of interview. In java int and Integer, both are used to store integer values. Integer is an object while int is not an object it is a data type. Integer is a class and it has various methods for manipulating, storing the data, and doing things to Integer.

int

◈   int is a primitive data type. Primitive data types are basic data types used by the programmers to create variables in their programs.

◈   Primitive data types start with small letters.

◈   int can never be null. Int data type used to store integer binary values only.

◈   We can not change its value or syntax.

Integer

◈   Integer is a wrapper class. Wrapper class encapsulates or wraps primitive data types (eg. int, char, byte, etc.,).

◈   Wrapper classes start with a capital letter even all the predefined classes in java start with a capital letter.

◈   Integer can be null i.e. we can assign a reference variable of Integer to null. It can throw NullPointerException if you are performing auto-boxing to convert Integer to int or vice-versa.

◈   Since Integer is a wrapper class, it can call several in-built methods defined in the class.

◈   Integer class helps us to convert int data object and to convert the object into int as per programmers requirement.

◈   By using Integer class, we can perform several operations like reverse(), rotateLeft(), rotateRight().

In java, every primitive type has an equivalent wrapper class. These are as follows:

Primitive data type Wrapper class  
int  Integer
char Character
float Float
byte Byte
short Short
long Long
double Double
boolean Boolean

Example of Integer vs int