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