Posts

How to get client Ip Address using Java HttpServletRequest

Hi, I am Malathi Boggavarapu working at Volvo Group and i live in Gothenburg, Sweden. I have been working on Java since several years and had vast experience and knowledge across various technologies. In this post we will see how to get IP address from HttpServletRequest.  For the web application which is not running behind the proxy server, we can directly get from the  HttpServletRequest  request object as below remoteAdr = request.getRemoteAddr(); For suppose if your web application is behind a proxy server, load balancer or Cloudfare then you should get client Ip address using the Http request header  X-Forwarded-For  ( XFF) . See below. private String getIpAddress(HttpServletRequest request) { String remoteAdr = "" ; if (request != null ){ remoteAdr = request.getHeader( "X-FORWADED-FOR" ); if (remoteAdr == null || "" .equals(remoteAdr)) { remoteAdr = request.getRemoteAddr();

Question and answers related to Sql queries

Hello, In this post, questions about oracle Sql would be placed with answers. From day to day this post will be updated with question and answers. I have got few questions today to post and hence i did. What would be the default size of varchar2 in oracle? The default size of varchar2 in oracle is 4k and the default value of varchar2 is 32k when it is being used as input parameter in stored procedure or a function. What would be the recommended size of database column to store IP address? There are two types of IP address. One is IPv4 and another one is IPv6. Each of the numbers between the periods in an IP address range between 0-255 which occupies one byte each. so the total recommended size for IPv4 addresses is 4*8 = 32 characters But IPv6 addresses are 128 bits as opposed to 32 bits (IPv4 addresses). IPV6 addresses are usually written as 8 groups of 4 hex digits seperated by colon (2001:0db8:85a3:0000:0000:8a2e:0370:7334. So 39 characters is recommende

Bash - Execute Pl/Sql script from Shell script

Hi, I am Malathi Boggavarapu working at Volvo Group and i live in Gothenburg, Sweden. I have been working on Java since several years and had vast experience and knowledge across various technologies. In this post we see how to build a bash script which executes pl/sql script, retrieve data and send it to graphite server using NetCat. We also go through various basic bash commands such as do/while, nc and also we use bash functions too. NetCat is used to connect to the servers and stream out the data to them. You can visit wiki to get basic understanding about it.  https://en.wikipedia.org/wiki/Netcat To understand what graphite is visit the following link https://graphiteapp.org/ Now let's start with pl/sql script to retrieve data inorder to send it to graphite server. Pl/sql script A table holds the size of each table exists in the database every 24hrs. The query is to get the latest record of each table and it's size and some other columns too.

Evolution of Bash, Writing and Executing Bash commands and Scripts

Image
Hi, I am Malathi Boggavarapu working at Volvo Group and i live in Gothenburg, Sweden. I have been working on Java since several years and had vast experience and knowledge across various technologies. In recent times i faced a situation where i need to write some bash scripts in my project that finally lead me to update my blog with Bash course. This course will guide you through various bash commands and also about writing bash scripts. This course addresses all the concepts with real time examples. So let's get started. What is Bash? Well, Bash is Born Again Shell. It's is a very popular command line interpreter or shell. It has a very long history starting with first Unix shell called Thompson Shell in 1971. Thompson shell has very minimalised features and lack many important features and is replaced with Mashey Shell in 1975. That inturn was replaced by Bourne Shell (sh) in 1977 which have many features that we still use such as command substitution

Brief History of Version Control Systems, DVCS Advantages and Git Installation

Image
Hi, I am Malathi Boggavarapu and welcome to my blog. This tutorial describes brief history of Version control systems, Advantages of DVCS which means Distributed Version Control Systems and also we will learn about Git and it's installation on Windows. I have a seperate post " Git Fundamentals " in my blog which explains everything about Git but i had broken them down to smaller sections to make it easy for everyone to follow. This post will only introduce you to Git. So let's get started. A brief history of version control First generation The very first version control system were developed in early 70's and operated on a single file and had no networking support.These were the systems such as SCCS and RCS. They are operated on a single file so that you will have a file such as foo.c and have multiple versions of that file. But there was no correspondence between different files within the repository. There was no notion that version 1.1

Git - Branching, Merging, Rebasing and Cherry-picking

Image
Hi, I am Malathi Boggavarapu and welcome to my blog. This tutorial describes about Branching, Merging and Rebasing with Git and also about Git stashing, Cherry-picking. I have a seperate post " Git Fundamentals " in my blog which explains everything about Git but i had broken them down to smaller sections to make it easy for everyone to follow. This post will only introduce you to Git. So let's get started. Branching, Merging and Rebasing with Git First we look at how to visualize the branches. We have already discussed about the command  git log --graph --oneline  which gives us the list of commits on the current branch using a graph on left hand side. Now we are going to add some more options to add the visualizers for our branches. git log --graph --online --all --decorate  -> all allows us to visualize all the branches rather than the current branch and decorate applies any labels to the commits such as HEAD, tags, remote branches and t

Git - Creating, Verifying Tags and Pushing Tags to remote repository

Image
Hi, I am Malathi Boggavarapu and welcome to my blog. This tutorial describes about creating and verifying tags in Git and pushing the tags to the remote repository. I have a seperate post " Git Fundamentals " in my blog which explains everything about Git but i had broken them down to smaller sections to make it easy for everyone to follow.  So let's get started. Creating and Veifying tags Lets look at tagging the repository. We can tag a repository by using the below commands git tag v1.0  - v1.0 is the tag name and it is an unsigned tag. git tag  - It shows the tags that were created git tag -a v1.0_with_message  - It will annotate or message to associate with a tag. git tag -s v1.0_signed  - We can sign a tag using this command. We can also verify the tags. To verify the created tags we use the following commands. See the picture. The above picture is very clear. For the programmer there is no need to explain further i believe. So