JDBC Statement vs PreparedStatement

  • 05 April 2016
  • ADM

JDBC Statement vs PreparedStatement with example. Comparison between around SQL Injection using SELECT query.


How to connect to MySQL with JDBC driver

  • 20 May 2016
  • ADM

How to connect to MySQL database with MySQL JDBC driver. Get a new connection using DriverManager class.


How to create Generic Object Pool in Java

  • 23 March 2016
  • ADM

In a application you can have resources that are limited or time consuming to create a new one. e.g. a connection to a database, a new thread. A solution is to create a the limited resource once and reuse it. To address this problem the object pool pattern was introduced. The object pool design will have the mechanism to create a new object to keep the objects and to destroy the objects if necessary.


How to create Singleton Design Pattern in Java

  • 14 May 2016
  • ADM

design pattern is a general solution to a common problem. The singleton pattern is used to restricts the instantiation of a class to one single object.


Change ssh default port in Linux

  • 20 May 2016
  • ADM

By default, ssh listens for incoming connections on port 22. So if a hacker wants to attack your machine he will most likely scan port 22 first. Just to make an idea how important is this (from my point of view of course), before changing the default ssh port for my server I got every day 1000+ login tries for my root user. An effective (but minimal) method to protect your machine is to run ssh on non-standard port. Any unused port will work but one above 1024 is preferable.


If statement vs try catch block

  • 07 March 2016
  • ADM

Real live comparison:

If statement is like walking on the cliff, on each step you need to check your stability otherwise you may fall into abyss.

Try/catch block is like walking on the street, you don't have to care about the road on each step, only when there is an obstacle (something exceptional is happening).