Database Connection Pooling 2

In software engineering, a connection pool is a cache of database connections maintained so that the connections can be reused when future requests to the database are required. Connection pools are used to enhance the performance of executing commands on a database. Opening and maintaining a database connection for each user, especially requests made to ...

Daemon Threads

A daemon thread is a thread, that does not prevent the JVM from exiting when the program finishes but the thread is still running. An example for a daemon thread is the garbage collection.     Daemon threads are like a service providers for other threads or objects running in the same process as the ...

Constructors and Methods

A constructor is a special method (not appropriate to call it a method but for the sake of analogy) whose task is to initialize the object of its class.It is special because its name is the same as the class name.They do not have return types, not even void and therefore they cannot return values. ...

Comparing java.util.Date with database time (java.sql.Timestamp) 1

And so it happened. I stumbled again and this time I was hit by mere milliseconds. Yeah!!! One sure would find a few milliseconds really insignificant but it gave me a real pain in the a** for a while. All I did was to compare a “cron expression” time (a java.util.Date object) with the timestamp ...

Classloaders – back to basics…

Classloaders - back to basics...
Regular java application running from command line involve three classloaders   Bootstrap Classloader  It is the parent of all the classloaders and loads  the standard JDK  classes in the lib directory of JRE (rt.jar and i18n.jar). All the “*. java ” classes are loaded by  this loader.   Extension Classloader  It is the immediate child of bootstrap ...

Class Methods and Instance Methods

 S.No.  Class Methods  Instance Methods  1. Class methods are methods which are declared as static. The method can be called without creating an instance of the class Instance methods on the other hand require an instance of the class to exist before they can be called, so an instance of a class needs to be ...

Characters for formatting a dateTime as String

Source   Symbol Meaning Presentation Examples a am or pm marker Text Input am, AM, pm, PM. Output AM or PM d day in month (1-31) Number 1, 20 dd day in month (01-31) Number 01, 31 D day in year (1-366) Number 3, 80, 100 DD day in year (01-366) Number 03, 80, 366 ...

Can we execute a program without main() method in java?

Yes, using static block (not possible from JDK 1.7 onwards)   for example: class A {  static {  String name = getName();  System.out.println(name); }   public static String getName() {  return “project code bank”; } }   output: project code bank Exception in thread “main” java.lang.NoSuchMethodError: main   using System.exit(0) in the static we can ...

Autoboxing and Unboxing 1

Autoboxing, introduced in Java 5, is the automatic conversion the Java compiler makes between the primitive (basic) types and their corresponding object wrapper classes (eg, int and Integer, double and Double, etc). The underlying code that is generated is the same, but autoboxing provides a sugar coating that avoids the tedious and hard-to-read casting typically ...

ArrayList and Vector

java.util.Vector was introduced with the first version of java development kit (JDK 1.1) and java.util.ArrayList  was introduced in java version 1.2 as a part of collections framework, later vector has also been retrofitted to implement List and became the part of the collections framework. Both ArrayList and Vector use array as a internal data structure and are dynamically resizable with default size zero and ...