Images

JDBC Architecture Model

JDBC is core part of java platform and is an API specification developed by Sun Microsystems. Nearly all relational DBMSs (Database Management Systems) support SQL, and JAVA itself runs on most platforms, JDBC makes it possible to write a single database application that can run on different platforms and interact with different DBMSs.

“JDBC is similar to ODBC, but specifically designed for JAVA while ODBC is language independent.”

The JDBC driver manager is a traditional backbone of the JDBC architecture, which specifies objects for connecting Java applications to a JDBC driver. The JDBC Test Suite helps to ensure that the JDBC drivers will run the program. The JDBC-ODBC Bridge software offers JDBC access via the open database connectivity drivers.

JDBC Architecture

The JDBC architecture supports two-tier and three-tier processing models for accessing a database.

Two-tier Model (Client/Server)

A Java applet or application communicates directly to the data source. The JDBC driver enables communication between the application and the data source. When a user sends a query to the data source, the answers for those queries are sent back to the user in the form of results. The data source may be located on  single machine or  different machine on a network to which a user is connected. This is known as a client/server configuration, where the user’s machine acts as a client and the machine having the data source running acts as the server. The network connection can be intranet or Internet.
JDBC Two Tiers Architecture

Three-tier Model

In this model having one more layer as middle tier where the user’s commands or queries are sent to middle-tier services, from which the commands are again sent to the data source. The results are sent back to the middle tier, and from there to the user. This type of model is found very useful to makes simple to maintain access control and make updates to corporate data in database. Application deployment also becomes easy and provides performance benefits. The middle tier is usually written in C or C++.

JDBC Three Tier Architecture

References

https://docs.oracle.com/javase/tutorial/jdbc/overview/architecture.html

More on JDBC

Follow below links to know more on JDBC and solving JDBC issues :

JDBC Tutorial

JDBC Sample Code

JDBC Issues and Solutions

JDBC Interview Questions And Answers

Advertisements

YAML Introduction

YAML(Ain’t Markup Language) is a human friendly , cross language, unicode based data serialization format designed for interaction with all programming languages.

File Name Extension : .yml or .yaml

Latest Release : 1.2

It is broadly use for programming:

  • Configuration Files
  • Internet Messaging
  • Object Persistence to data auditing
  • Also support for Unicode standards characters.

YAML allow data to show itself in a natural and meaningful way and provide a unique cleanness by minimizing the amount of structural characters.
For example: indentation may be used for structure, colons use to separate “mapping key: value” pairs, and dashes are used to create “bullet” lists for showing collections of data.

YAML is a superset of JSON : you can convert YAML to JSON by different API’s

YAML Goals

Below are main design goals for YAML :

  • YAML is easily readable and understandable by humans.
  • YAML is expressive and extensible.
  • YAML is easy to implement and use.
  • YAML matches the native data structures of agile languages.
  • YAML data is portable between programming languages.
  • YAML has a consistent model to support generic tools.
  • YAML supports one-pass processing.

YAML Documents Processing

A YAML document is parsed only when the iterator is invoked (lazy evaluation).

More

To know more about YAML Syntax, Configuration with Java and other supporting language, frameworks and tools, Sample configuration files and JSON and YAML conversion follow below YAML Tutorials and YAML related exceptions follow YAML Issues.

 

Marker Interface in Java and Use

Marker interface is main frequently asked question to JAVA interview. Generally interviewer asked this question to check internal know knowledge of JAVA developer some times ask on architect level also because it’s follow the Marker Interface Design pattern. Here I have covered everything to crack questions related to Marker Interface.

What is a Marker Interface?

Marker Interfaces are empty interface it does not contains any properties and behaviors to implement. It’s also called as marker or the tag interface.

Why Marker Interface and Who Implement it?

Custom Marker Interface Example
Custom Marker Interface

Marker interface functionality is predefined implicitly in JVM. When a class implement a marker interface then class is not expected to implement anything to adhere to the contract defined by the interface. In contrast it is a tag to indicate the JVM regarding an expected functionality to perform implicitly.

For Example :

java.io.Serializable : If class implements the Serializable interface then JVM perform some special operation on it and writes the state of the object into object stream then this object stream will available to read by another JVM.

java.lang.Cloneable: Same way if class is implementing Cloneable interface then it perform some special operation to clone object by copy all fields

What are available Marker Interfaces in JAVA?

Mainly used built-in marker interfaces are as below :

  • java.lang.Cloneable
  • java.io.Serializable
  • java.rmi.Remote
  • java.util.EventListener (its officially know as ‘tagging interface’)

There are some more marker interface present in Java.

  • java.util.concurrent.CompletableFuture.AsynchronousCompletionTask
  • java.sql.ParameterMetaData
  • javax.xml.stream.events.EndDocument
  • javax.management.loading.PrivateClassLoader
  • java.security.KeyStore.Entry
  • java.security.KeyStore.LoadStoreParameter
  • java.security.KeyStore.ProtectionParameter
  • java.security.Policy.Parameters
  • javax.security.auth.callback.Callback
  • javax.security.auth.login.Configuration.Parameter

Can we create custom marker interfaces ?

Yes

How to Create Custom marker Interfaces?

Custom Marker Interface is nothing to do specially with JVM end . It’s to mentioned in class methods to treat this object specially so that perform some special operations.

Steps to create marker interface :

  • Create an interface with no properties and method on it.
  • Implements this interface on class.
  • Perform any operation in method if object instance of type marker interface.

See below example for more detail

Create Empty  Interface

public interface MyMarker {
//no properties and method
}

Write a class to implement interface

public class MyClass implements MyMarker{
//define properties and method
}

Class to check Marker Interface to perform special operation

public class TestMarker {

	public static void main(String[] args) {
		MyClass myClass=new MyClass();

		if(myClass instanceof MyMarker)
		{
			System.out.println("I am special treat me VIP");
		}

	}

}

Output :

I am special treat me VIP

Summary

  • Explained about Marker Interface and how JVM handle Marker Interface.
  • Available Marker Interface in Java with some example.
  • Creation of Custom Marker Interface and use.