Thursday 21 March 2019

loading the jdbc driver classes vs registering the driver classes

Automatic registration is a requirement for a JDBC4-compliant driver, in such cases you can skip the manual registration. A JAR file can automatically register the driver class if it contains a file META-INF/services/java.sql.Driver.


If your driver’s JAR file doesn’t support automatic registration, you need to find out the name of the JDBC driver classes used by your vendor.

There are two ways to register the driver with the DriverManager.

One way is to load the driver class in your Java program. For example - 

Class.forName("org.postgresql.Driver"); // force loading of driver class

This statement causes the driver class to be loaded, thereby executing a static initializer that registers the driver.

The other way is your application can set the system property

System.setProperty("jdbc.drivers", "org.postgresql.Driver");

you can also set the jdbc.drivers property. You can specify the property with a command-line argument


java -Djdbc.drivers=org.postgresql.Driver ProgramName


Saturday 2 March 2019

Hello GIT

Hello Git 

Git Basics - 

How to start with GIT project ?
1. You can create an new project upload this project to get repository.
2. Clone the project from git repository.  

Getting started with creating new project - 
1. Install git 
2. go to directory where you want to create new project
3. execute command git init 
4. go to folder and you will see an sub-directory .git , the .git folder contains all the meta files.







Cloning the project from repository - 
Cloning is getting the copy of project from git repository
1. To clone project use below command
             git clone git://url/project.git  target-directory-where-you-want-to-copy-file
2. in the above example protocol used to clone was git , you may also see  http(s):// or user@server:/path.git, which uses the SSH transfer protocol  

Once the project has been created, you would need to perform various operations on files like committing your changes, deleting files, tracking changes, etc , All this recording your changes - 

File status life Cycle in git 
1. Files are either tracked or are untracked.
2. tracked files are all version controlled  by git
3. untracked files are not version controlled by git, git doesn't take of these files
4. when you clone a repository, all files are tracked & unmodified , if you edit any of these files then, git sees these files as modified.
5. Next step is to stage the files.  



What is staging area ? and its significance ?
Before you commit, files you need to stage file. 
Staged means the file has been added to git's version control but changes have not been committed

What is Staging ?
Staging gives you flexibility to commit your changes to git repository. 

How ?
Suppose you are working on 2 features. 
1. Feature-1 
    - file1.py
    - file2.py
2. Feature-2
   - file3.py
Feature-1 development is completed, but you are still working on Feature-2. You would like to commit all your Feature-1 changes to git repository, All you need to do is stage all your Feature-1 changes and commit. And once you are done with your Feature-2 changes, stage and commit all your Feature-2 changes.

Lets try, what git command need to be used to manage the life cycle of file in git.

Continuing with previous example - test-project , which was an new git repository created.

1. Checking the status

2. add new file, i have created an new folder app and created new file index.html

test-project
  - app
     - index.html

3. Now lets check the status of file, git does not manages/considers untracked files.  
How to track files ?



4. How to Track files ?
git add file-name

5. What is the status after the files have been added?
The changes have been staged, but not yet committed.    

6. lets modify the index.html file. and run the git status command



Work IN PROGRESS









Monday 25 February 2019

Running Bash Script

1. $PATH  ensure the path is correct
2. Consider storing script in $User/bin which is /usr/local/bin
3. Run the script using ./srcipt-name . refers to current directory
4. in order to run the script, the script should have execute permission, to give permission
          chmod   +x myscript
5. bash myscript to run script.
6. executing script ./script-name i.e. executing without ./ can return un-expected results. to validate execute the command using which command.


Exit And Exit Status

The exit command terminates the script & returns an value, this value is available with the scripts parent process. 

A successful exit returns 0, while an un-successful exit returns value greater than 0


Linux shell shebang

Starting an script with #!  is called shebang or bang line. 
This is the absolute path to Bash interpreter. 
Almost all bash scripts often begin with the #!bin/bash. 
This ensures that Bash will be used to interpret the script. 

If you do not specify an interpreter line, the default is usually the /bin/sh. But, it is recommended that you set #!/bin/bash line    

Saturday 23 February 2019

TWO's COMPLEMENT

This section is divided into
1. What is the significant of LSB
2. What is the Significant of MSB
3. What is Complement in computer science
4. What is One's Complement
5. What is Two's complement

Least significant bit - 
The least significant bit in the Binary number is the UNIT value,  Least significant bit helps to determine if the number is the ODD or the EVEN Number.

How to determine if the number is ODD or EVEN ?
The simplest way is to use modulo(%) operator 

pseudo code - 
if  no % 2 == 0 then
     print "even number"
else 
     print "odd number"

using binary operation ?
example number 2 in binary format is represented as 10 and number 3 in binary format is represented as 11

Bit-wise  And (&) operator can be used to determine if the number is the ODD no or EVEN no.
Truth Table
1 & 1 = 1
1 & 0 = 0
0 & 1 = 0 

hence 

Binary format of 2 -->    1  0
Binary format of 1 -->    0  1
                                     &
--------------------------------------
                                            0

Hence the no is even no

     
Binary format of 3 -->    1  1
Binary format of 1 -->    0  1
                                     &
--------------------------------------
                                            1

Hence the no is ODD No


Most significant bit - 
Most significant bit is the (or higher order bit) is the bit position in binary number having greatest value.

The MSB can also correspond to the sign bit of a signed binary number in one's or two's complement notation, "1" meaning negative and "0" meaning positive


What is Complement in Computer Science ?

the method of complements is a technique used to subtract one number from another using only addition of positive numbers.

One's complement

One's complement is inverting bit i.e changing '0' to '1' and vice versa .

Two's Complement

do One's complement  and add one. 

example 
100 - 22 = ?








Saturday 9 February 2019

Angular Interview Questions

1.What is the difference between Angular Module & ES 2015 Module ?
2.