Posts

Advantages of Spring JdbcTemplate over JDBC API

Advantages of Spring JdbcTemplate over JDBC API        Spring JdbcTemplate is a powerful mechanism to connect to the database and execute SQL queries. It internally uses JDBC API, but eliminate the lot of problems of JDBC API. Problems While using JDBC API :-  The common problems while using JDBC API are as below, 1) We need to write a lot of code before and after executing the query such as creating connection,      statement and resultset and closing the resultset, statement and connection etc. 2) We need to perform exception handling code on the database logic. 3) We need to handle transaction. 4) Repetition of these codes i.e connection, statement and resultset codes for every transaction, so it's     time consuming task. Advantages of Spring JdbcTemplate :          Spring provides simplification in handling database access with the Spring JdbcTemplate which is in org.springframework.j...

Transaction Management in Spring

Image
Transaction Management in Spring           This article we can discuss about Spring Transaction Management with simple examples.          A transaction is a logical unit of work that contains one or more statements. A transaction is an atomic unit. The effects of all the statements in a transaction can be either all committed or all rolled back. See the below diagram to show the transaction management,       Transaction management is an important part of enterprise applications to ensure data integrity and consistency.             The concept of transactions can be described as ACID(Atomicity, Consistency,  Isolation, Durability) property: Atomicity:           Atomicity requires that each transaction is “all or nothing”  which means either the sequence of a transaction is successful or unsuccessful.        If one part o...

Difference between Loose Coupling and Tight Coupling in Java With Examples

First to understand what is Loose coupling and Tight coupling and also to know the  advantage of loose coupling. Loose coupling means reducing the dependencies of a class that uses the different classes directly.  Tight coupling means classes and objects are dependent on one another. In general tight coupling is usually not good because it reduces flexibility and re-usability of code and it makes changes much more difficult and not easy to test. Tight Coupling:-       Tightly coupled object is an object that needs to know quite a bit about other objects and are usually highly dependent on each other's interfaces. Changing one object in a tightly coupled application often requires changes to a number of other objects. In a small application we can easily identify the changes and there is less chance to miss anything. But in large applications these inter-dependencies are not always known by every programmer and there is chance of overlooking changes.(...

Learn more about rdd in spark

RDD (Resilient Distributed Dataset) is called the elastic distributed data set. It is the most basic data abstraction in Spark. It represents an immutable, partitionable, and set of elements that can be calculated in parallel. RDD has the characteristics of a data flow model: automatic fault tolerance, location-aware scheduling, and scalability. RDD allows users to explicitly cache the working set in memory when executing multiple queries. Subsequent queries can reuse the working set, which greatly improves query speed. Today, let's talk briefly about RDD in Spark. The RDD API will be put into the next chapter and then detailed RDD Introduction RDD can be regarded as an object of Spark, which runs in memory itself. For example, reading a file is an RDD, calculating a file is an RDD, and the result set is also an RDD. Different shards, data dependencies, key- Value type map data can be regarded as RDD. (Note: from Baidu Encyclopedia), here, RDD will not say much, just talk abou...

Getting started with Vue.js | Make an application from scratch

Image
Before starting to write code, first go to the BootCDN to find the link to the latest version of the full version of Vue.js: https://cdn.bootcss.com/vue/2.6.10/vue.js , and the compressed version (vue. min.js), it (vue.js) contains a complete warning and debugging mode. In order to keep it as simple as possible, this article does not use the Vue CLI to build the project, but instead introduces the Vue.js file directly into the HTML file as developed with jQuery. If the code in the article does not understand something, my suggestion is: copy the code directly, see the effect, see the documentation, change the code, see the effect, and so on. Declarative rendering To understand the "Declarative Rendering" part of the basic part of Vue's official website , we can create the following code: Preview the index.html file at this time and you will see the text Hello, Vue.js! on the page. Component structure We split the To-Do App to be divided into small compo...

Angular Arrow functions

One thing I like a lot in ES2015 is the new arrow function syntax, using the 'fat arrow' operator (⇒). It is SO useful for callbacks and anonymous functions! Let’s take our previous example with promises: getUser(login)   .then(function (user) {   return getRights(user); // getRights is returning a promise   })   .then(function (rights) {   return updateMenu(rights);   }) can be written with arrow functions like this: getUser(login)   .then(user => getRights(user))   .then(rights => updateMenu(rights)) How cool is it? THAT cool! Note that the return is also implicit if there is no block: no need to write user ⇒ return getRights(user). But if we did have a block, we would need the explicit return: getUser(login)   .then(user => {   console.log(user);   return getRights(user);   })   .then(rights => updateMenu(rights)) And it has a special trick, a great power over normal functions: the...

Understand Promises in Angular

Promises aim to simplify asynchronous programming. Our JS code is full of async stuff, like AJAX requests, and usually we use callbacks to handle the result and the error. But it can get messy, with callbacks inside callbacks, and it makes the code hard to read and to maintain. Promises are much nicer than callbacks, as they flatten the code, and thus make it easier to understand. Let’s consider a simple use case, where we need to fetch a user, then their rights, then update a menu when we have these. With callbacks: getUser(login, function (user) {   getRights(user, function (rights) {   updateMenu(rights);   }); }); Now, let’s compare it with promises: getUser(login)   .then(function (user) {   return getRights(user);   })   .then(function (rights) {   updateMenu(rights);   }) I like this version, because it executes as you read it: I want to fetch a user, then get their rights, then update the menu. As you can see, a pro...